From 69e4ea9204baa4035e8cd618688ac8f63fa21661 Mon Sep 17 00:00:00 2001 From: Brendan Haines Date: Fri, 2 Jul 2021 03:20:38 -0600 Subject: [PATCH] clean up core_tb.v a little --- hdl/tb/core_tb.v | 34 ++++++---------------------------- test/test.S | 6 ++++++ 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/hdl/tb/core_tb.v b/hdl/tb/core_tb.v index 07e0ea2..46163f6 100644 --- a/hdl/tb/core_tb.v +++ b/hdl/tb/core_tb.v @@ -25,36 +25,23 @@ localparam DATA_INVALID = 32'hdeadbeef; reg clk, reset; -// Instruction memory +// Memory reg [31:0] mem [0:MEM_LENGTH-1]; +initial $readmemh("text.hex", mem); + +// Instruction Memory wire [31:0] mem_inst_addr; wire [31:0] mem_inst_idx = mem_inst_addr >> 2; wire [31:0] mem_inst_data = mem_inst_idx < MEM_LENGTH ? mem[mem_inst_idx] : INST_NOP; -initial begin: mem_init - // integer i; - // for (i=0; i> 2; +wire [31:0] mem_data_rdata = mem_data_idx < MEM_LENGTH ? mem[mem_data_idx] : DATA_INVALID; wire [31:0] mem_data_wdata; wire [3:0] mem_data_wmask; wire mem_data_we; -// initial begin: mem_data_init -// integer i; -// for (i=0; i> 2; -always @(*) begin - if (mem_data_idx < MEM_LENGTH) begin - mem_data_rdata = mem[mem_data_idx]; - end else begin - mem_data_rdata = DATA_INVALID; - end -end - always @(posedge clk) begin if (mem_data_idx < MEM_LENGTH && mem_data_idx >= MEM_ROM_LENGTH) begin if (mem_data_we) begin diff --git a/test/test.S b/test/test.S index 1e8cd9e..9f11e27 100644 --- a/test/test.S +++ b/test/test.S @@ -372,6 +372,12 @@ test_jalr: .data someint: .word 0xfedcba98 +someint16: + .byte 0x1122 +someint8: + .byte 0xaa +anotherint8: + .byte 0xbb .bss anotherint: