diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-10 20:16:09 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-10 20:16:09 +0300 |
commit | b1ee83cd1ea325a5d353365ac35790a7c1d47845 (patch) | |
tree | fcb4157129bbc3cb84a3990edb15fddda5f9806a /src/ttarv32.sv | |
parent | 373edb42380875eafc8b9de54d80b939d263d041 (diff) | |
download | ttarv32-b1ee83cd1ea325a5d353365ac35790a7c1d47845.tar.gz ttarv32-b1ee83cd1ea325a5d353365ac35790a7c1d47845.zip |
+ Not fully functional, but good enough for now
Diffstat (limited to 'src/ttarv32.sv')
-rw-r--r-- | src/ttarv32.sv | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/src/ttarv32.sv b/src/ttarv32.sv index 0edf1cb..cb04824 100644 --- a/src/ttarv32.sv +++ b/src/ttarv32.sv @@ -1,8 +1,9 @@ `include "common.svh" +`default_nettype none + module ttarv32 #( parameter SLOT_COUNT, - parameter SLOT_DEPTH, parameter ALU_COUNT )( input clk_i, @@ -13,7 +14,7 @@ module ttarv32 #( typedef struct packed { mov_t[1:0] in; - mov_t[SLOT_DEPTH-1:0] out; + mov_t out; op_t op; imm_t imm; } slot_t; @@ -39,63 +40,44 @@ rv2insn #( .que_o(rv_que) ); -typedef struct packed { - insn_t[SLOT_COUNT-1:0] que; - xlen_t pc; -} merge_t; - -/* repetition from sched.sv, hmm */ -function automatic insn_t[SLOT_COUNT-1:0] next_insn(insn_t[SLOT_COUNT-1:0] que); - return que >> $bits(insn_t); -endfunction - -function automatic logic is_noop(mov_t m); - return m.src == NOP && m.dst == NOP; -endfunction - -/* not the best thing in the world but good enough for now */ -function automatic logic is_free(insn_t i); - return is_noop(i.in[0]) & is_noop(i.in[1]) & is_noop(i.out); +function automatic insn_t[SLOT_COUNT-1:0] merge(insn_t[SLOT_COUNT-1:0] prev_que, insn_t[SLOT_COUNT-1:0] decoded, bit[$clog2(SLOT_COUNT)-1:0] shift); + return prev_que | (decoded << (shift * $bits(insn_t))); endfunction -function automatic merge_t merge(int i, - insn_t[SLOT_COUNT-1:0] prev_que, insn_t[SLOT_COUNT-1:0] next_que, xlen_t pc); - if (i < SLOT_COUNT) begin - logic ok = is_free(prev_que[i]); - prev_que[i] = ok ? next_que[0] : prev_que[i]; - return merge(i + 1, - prev_que, - ok ? next_insn(next_que) : next_que, - ok ? pc + 1 : pc); - end else begin - return {prev_que, pc}; - end -endfunction +bit[$clog2(SLOT_COUNT)-1:0] shift_r, shift; -merge_t merged; -assign merged = merge(0, prev_que_r, rv_que, pc_r); +insn_t[SLOT_COUNT-1:0] merged_que; +assign merged_que = merge(prev_que_r, rv_que, shift_r); sched #( .QUE_DEPTH(SLOT_COUNT), .SLOT_COUNT(SLOT_COUNT), - .SLOT_DEPTH(SLOT_DEPTH), .slot_t(slot_t) ) sched ( - .que_i(merged.que), + .clk_i(clk_i), + .rst_ni(rst_ni), + .que_i(merged_que), .que_o(next_que), .slots_i(prev_slots_r), - .slots_o(next_slots) + .slots_o(next_slots), + .shift_o(shift) ); always_ff @(posedge clk_i or negedge rst_ni) begin if (!rst_ni) begin prev_slots_r <= 0; - prev_que_r <= 0; + prev_que_r <= 0; + shift_r <= 0; + pc_r <= 0; + pc_o <= 0; end else begin prev_slots_r <= next_slots; - prev_que_r <= next_que; - pc_r <= merged.pc; + prev_que_r <= next_que; + shift_r <= shift; + + pc_o <= pc_r + xlen_t'(shift); + pc_r <= pc_o; end end |