USTC-RVSoC/ASM/simpletest.sv
2019-02-05 16:19:46 +08:00

30 lines
700 B
Systemverilog

// asm file name: test1.S
module instr_rom(
input logic clk, rst_n,
input logic [13:0] i_addr,
output logic [31:0] o_data
);
localparam INSTR_CNT = 12'd5;
wire [0:INSTR_CNT-1] [31:0] instr_rom_cell = {
32'h21006093,
32'h0210e113,
32'h00111193,
32'h5681f213,
32'h68a06293
};
logic [11:0] instr_index;
logic [31:0] data;
assign instr_index = i_addr[13:2];
assign data = (instr_index>=INSTR_CNT) ? 0 : instr_rom_cell[instr_index];
always @ (posedge clk or negedge rst_n)
if(~rst_n)
o_data <= 0;
else
o_data <= data;
endmodule