From 82dec45fd786831f791b17b84aedb4d99b5ca25d Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 16 Feb 2025 20:55:24 +0200 Subject: add initial risc-v -> tta translation block --- tb/sched_tb.sv | 84 ++++++++++------------------------------------------------ 1 file changed, 14 insertions(+), 70 deletions(-) (limited to 'tb/sched_tb.sv') diff --git a/tb/sched_tb.sv b/tb/sched_tb.sv index 8db66b3..036464e 100644 --- a/tb/sched_tb.sv +++ b/tb/sched_tb.sv @@ -2,62 +2,11 @@ module sched_tb; -typedef enum logic [7:0] { - NOP = `NOP, - R0, - R1, - R2, - R3, - R4, - R5, - R6, - R7, - R8, - R9, - R10, - R11, - R12, - R13, - R14, - R15, - R16, - R17, - R18, - R19, - R20, - R21, - R22, - R23, - R24, - R25, - R26, - R27, - R28, - R29, - R30, - R31, - - ALU0, - ALU1 -} port_t; - -typedef logic [19:0] op_t; - -typedef struct packed { - port_t src; - port_t dst; -} mov_t; - -typedef struct packed { - mov_t[1:0] in; - mov_t out; - op_t op; -} insn_t; - typedef struct packed { mov_t[1:0] in; mov_t[0:0] out; op_t op; + imm_t imm; } slot_t; slot_t[1:0] prev_slots; @@ -69,9 +18,6 @@ sched #( .QUE_DEPTH(3), .SLOT_COUNT(2), .SLOT_DEPTH(1), - .port_t(port_t), - .mov_t(mov_t), - .insn_t(insn_t), .slot_t(slot_t) ) sched ( .que_i(prev_que), @@ -80,16 +26,14 @@ sched #( .slots_o(next_slots) ); -`define assert(signal, value) \ - if (signal !== value) begin \ - $error("%m: signal != value"); \ - end +slot_t[1:0] first_check = {76'b0, + {{`rn(2), `alu(0)}, {`rn(3), `alu(0)}, {`alu(0), `rn(1)}, 8'h1, 20'h123} + }; -slot_t[1:0] first_check = {68'b0, {R2, ALU0}, {R3, ALU0}, {ALU0, R1}, 20'h123}; slot_t[1:0] second_check = { - {{R2, ALU0}, {R1, ALU0}, {ALU0, R5}, 20'h789}, - {{R2, ALU1}, {R1, ALU1}, {ALU1, R4}, 20'h456} - }; + {{`rn(2), `alu(0)}, {`rn(1), `alu(0)}, {`alu(0), `rn(5)}, 8'h3, 20'h789}, + {{`rn(2), `alu(1)}, {`rn(1), `alu(1)}, {`alu(1), `rn(4)}, 8'h2, 20'h456} + }; initial begin $dumpfile("sched_tb.vcd"); @@ -105,12 +49,12 @@ initial begin * add r4, r2, r1 add r5, r2, r1 */ prev_que = { - /* src2, src1, out, op, apparently. Have to get used to - * systemverilog's way of laying out bits, huh. */ - {{R2, ALU0}, {R1, ALU0}, {ALU0, R5}, 20'h789}, - {{R2, ALU1}, {R1, ALU1}, {ALU1, R4}, 20'h456}, - {{R2, ALU0}, {R3, ALU0}, {ALU0, R1}, 20'h123} - /* also, 'reverse' order, first instruction at bottom */ + /* src2, src1, out, op, apparently. Have to get used to + * systemverilog's way of laying out bits, huh. */ + {{`rn(2), `alu(0)}, {`rn(1), `alu(0)}, {`alu(0), `rn(5)}, 8'h3, 20'h789}, + {{`rn(2), `alu(1)}, {`rn(1), `alu(1)}, {`alu(1), `rn(4)}, 8'h2, 20'h456}, + {{`rn(2), `alu(0)}, {`rn(3), `alu(0)}, {`alu(0), `rn(1)}, 8'h1, 20'h123} + /* also, 'reverse' order, first instruction at bottom */ }; prev_slots = '0; @@ -118,7 +62,7 @@ initial begin #10 assert (next_slots == first_check) - else $error("\nwanted:\t%h", first_check, "\ngot:%h\t", next_slots); + else $error("\nwanted:\t%h", first_check, "\ngot:\t%h", next_slots); /* pretend all operations finished */ prev_slots = '0; -- cgit v1.2.3