Обновление тестбенчей

This commit is contained in:
Andrei Solodovnikov
2024-09-09 12:01:27 +03:00
parent ecd342b022
commit e9665941f9
14 changed files with 302 additions and 343 deletions

View File

@@ -11,33 +11,36 @@ See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details.
module lab_01_tb_fulladder(); module lab_01_tb_fulladder();
logic tb_a_i; logic tb_a_i;
logic tb_b_i; logic tb_b_i;
logic tb_carry_i; logic tb_carry_i;
logic tb_carry_o; logic tb_carry_o;
logic tb_sum_o; logic tb_sum_o;
logic [2:0] test_case; logic [2:0] test_case;
fulladder DUT ( fulladder DUT (
.a_i(tb_a_i), .a_i(tb_a_i),
.b_i(tb_b_i), .b_i(tb_b_i),
.sum_o(tb_sum_o), .sum_o(tb_sum_o),
.carry_i(tb_carry_i), .carry_i(tb_carry_i),
.carry_o(tb_carry_o) .carry_o(tb_carry_o)
); );
assign {tb_a_i, tb_b_i, tb_carry_i} = test_case; assign {tb_a_i, tb_b_i, tb_carry_i} = test_case;
initial begin initial begin
$display("\nTest has been started\n"); $display("\nTest has been started\n");
#5ns;
test_case = 3'd0;
repeat(8) begin
#5ns; #5ns;
test_case = 3'd0; test_case++;
repeat(8) begin
#5ns;
test_case++;
end
$display("\nTest has been finished. Check results at waveform window.\n");
$finish();
end end
$display("\nTest has been finished. Check results at waveform window.\n");
$finish();
#5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end
endmodule endmodule

View File

@@ -11,72 +11,75 @@ See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details.
module lab_01_tb_fulladder32(); module lab_01_tb_fulladder32();
logic [31:0] tb_a_i; logic [31:0] tb_a_i;
logic [31:0] tb_b_i; logic [31:0] tb_b_i;
logic tb_carry_i; logic tb_carry_i;
logic tb_carry_o; logic tb_carry_o;
logic [31:0] tb_sum_o; logic [31:0] tb_sum_o;
logic clk = 0; logic clk = 0;
always #5ns clk = ~clk; always #5ns clk = ~clk;
int err_cnt = 0; int err_cnt = 0;
fulladder32 DUT ( fulladder32 DUT (
.a_i(tb_a_i), .a_i(tb_a_i),
.b_i(tb_b_i), .b_i(tb_b_i),
.sum_o(tb_sum_o), .sum_o(tb_sum_o),
.carry_i(tb_carry_i), .carry_i(tb_carry_i),
.carry_o(tb_carry_o) .carry_o(tb_carry_o)
); );
initial begin initial begin
$display("Test has been started"); $display("Test has been started");
sequential_add_test(); sequential_add_test();
random_test(); random_test();
$display("\nTest has been finished\nNumber of errors: %d\n", err_cnt); $display("\nTest has been finished\nNumber of errors: %d\n", err_cnt);
$finish(); $finish();
end #5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end
task sequential_add_test(); task sequential_add_test();
@(posedge clk); @(posedge clk);
tb_a_i = 0; tb_a_i = 0;
tb_b_i = 0; tb_b_i = 0;
tb_carry_i = 0; tb_carry_i = 0;
@(posedge clk); @(posedge clk);
for(int i = 0; i < 16; i++) begin for(int i = 0; i < 16; i++) begin
tb_a_i += 256; tb_a_i += 256;
for(int j = 0; j < 16; j++) begin for(int j = 0; j < 16; j++) begin
tb_b_i += 256; tb_b_i += 256;
tb_carry_i = ~tb_carry_i; tb_carry_i = ~tb_carry_i;
@(posedge clk);
end
end
endtask
task random_test();
repeat(1e4) begin
tb_a_i = $urandom();
tb_b_i = $urandom();
tb_carry_i = $urandom_range(1);
@(posedge clk); @(posedge clk);
end end
endtask
logic [32:0] reference;
assign reference = {1'b0, tb_a_i} + {1'b0, tb_b_i} + tb_carry_i;
sum_check: assert property (
@(negedge clk)
reference === {tb_carry_o, tb_sum_o}
)
else begin
err_cnt++;
$error("\noperands : a_i = 0x%08h, b_i = 0x%08h, carry_i = %b\nyour res : sum = 0x%08h, carry_o = %b\nreference: sum = 0x%08h, carry_o = %b",
tb_a_i, tb_b_i, tb_carry_i, tb_sum_o, tb_carry_o, reference[31:0], reference [32]);
if(err_cnt == 10) begin
$display("\nTest has been stopped after 10 errors");
$stop();
end
end end
endtask
task random_test();
repeat(1e4) begin
tb_a_i = $urandom();
tb_b_i = $urandom();
tb_carry_i = $urandom_range(1);
@(posedge clk);
end
endtask
logic [32:0] reference;
assign reference = {1'b0, tb_a_i} + {1'b0, tb_b_i} + tb_carry_i;
sum_check: assert property (
@(negedge clk)
reference === {tb_carry_o, tb_sum_o}
)
else begin
err_cnt++;
$error("\noperands : a_i = 0x%08h, b_i = 0x%08h, carry_i = %b\nyour res : sum = 0x%08h, carry_o = %b\nreference: sum = 0x%08h, carry_o = %b",
tb_a_i, tb_b_i, tb_carry_i, tb_sum_o, tb_carry_o, reference[31:0], reference [32]);
if(err_cnt == 10) begin
$display("\nTest has been stopped after 10 errors");
$stop();
end
end
endmodule endmodule

View File

@@ -11,33 +11,36 @@ See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details.
module lab_01_tb_fulladder4(); module lab_01_tb_fulladder4();
logic [3:0] tb_a_i; logic [3:0] tb_a_i;
logic [3:0] tb_b_i; logic [3:0] tb_b_i;
logic tb_carry_i; logic tb_carry_i;
logic tb_carry_o; logic tb_carry_o;
logic [3:0] tb_sum_o; logic [3:0] tb_sum_o;
logic [8:0] test_case; logic [8:0] test_case;
fulladder4 DUT ( fulladder4 DUT (
.a_i(tb_a_i), .a_i(tb_a_i),
.b_i(tb_b_i), .b_i(tb_b_i),
.sum_o(tb_sum_o), .sum_o(tb_sum_o),
.carry_i(tb_carry_i), .carry_i(tb_carry_i),
.carry_o(tb_carry_o) .carry_o(tb_carry_o)
); );
assign {tb_a_i, tb_b_i, tb_carry_i} = test_case; assign {tb_a_i, tb_b_i, tb_carry_i} = test_case;
initial begin initial begin
$display("Test has been started"); $display("Test has been started");
#5ns;
test_case = 9'd0;
repeat(512) begin
#5ns; #5ns;
test_case = 9'd0; test_case++;
repeat(512) begin
#5ns;
test_case++;
end
$display("\nTest has been finished Check results at waveform window.\n");
$finish();
end end
$display("\nTest has been finished Check results at waveform window.\n");
$finish();
#5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end
endmodule endmodule

View File

@@ -63,6 +63,9 @@ initial
direct_test(); direct_test();
$display("\nTest has been finished\nNumber of errors: %d\n", err_cnt); $display("\nTest has been finished\nNumber of errors: %d\n", err_cnt);
$finish(); $finish();
#5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end end
task X_test(); task X_test();
@@ -247,23 +250,22 @@ end
endmodule endmodule
parameter ALUOP_W = 5;
parameter OP_W = 32;
parameter SHIFT_W = $clog2(OP_W);
parameter STAGE_LEN = OP_W+1;
parameter HASH_LEN = 1000;
parameter START_CODING = 10366;
parameter START_MUX = START_CODING+100;
module alu_ref ( module alu_ref (
input logic [ALUOP_W-1:0] alu_op_i, input logic [ 4:0] alu_op_i,
input logic [OP_W-1:0] a_i, input logic [31:0] a_i,
input logic [OP_W-1:0] b_i, input logic [31:0] b_i,
output logic [OP_W-1:0] result_o, output logic [31:0] result_o,
output logic flag_o output logic flag_o
); );
localparam ALUOP_W = 5;
localparam OP_W = 32;
localparam SHIFT_W = $clog2(OP_W);
localparam STAGE_LEN = OP_W+1;
localparam HASH_LEN = 1000;
localparam START_CODING = 10366;
localparam START_MUX = START_CODING+100;
genvar i, j, k; genvar i, j, k;

View File

@@ -10,146 +10,149 @@ See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details.
*/ */
module lab_03_tb_register_file(); module lab_03_tb_register_file();
logic CLK; logic CLK;
logic [ 4:0] RA1; logic [ 4:0] RA1;
logic [ 4:0] RA2; logic [ 4:0] RA2;
logic [ 4:0] WA; logic [ 4:0] WA;
logic [31:0] WD; logic [31:0] WD;
logic WE; logic WE;
logic [31:0] RD1; logic [31:0] RD1;
logic [31:0] RD2; logic [31:0] RD2;
logic [31:0] RD1ref; logic [31:0] RD1ref;
logic [31:0] RD2ref; logic [31:0] RD2ref;
register_file DUT( register_file DUT(
.clk_i (CLK), .clk_i (CLK),
.read_addr1_i (RA1), .read_addr1_i (RA1),
.read_addr2_i (RA2), .read_addr2_i (RA2),
.write_addr_i (WA ), .write_addr_i (WA ),
.write_data_i (WD ), .write_data_i (WD ),
.write_enable_i(WE ), .write_enable_i(WE ),
.read_data1_o (RD1), .read_data1_o (RD1),
.read_data2_o (RD2) .read_data2_o (RD2)
); );
register_file_ref DUTref( register_file_ref DUTref(
.clk_i (CLK ), .clk_i (CLK ),
.read_addr1_i (RA1 ), .read_addr1_i (RA1 ),
.read_addr2_i (RA2 ), .read_addr2_i (RA2 ),
.write_addr_i (WA ), .write_addr_i (WA ),
.write_data_i (WD ), .write_data_i (WD ),
.write_enable_i(WE ), .write_enable_i(WE ),
.read_data1_o (RD1ref), .read_data1_o (RD1ref),
.read_data2_o (RD2ref) .read_data2_o (RD2ref)
); );
integer i, err_count = 0; integer i, err_count = 0;
parameter CLK_FREQ_MHz = 100; parameter CLK_FREQ_MHz = 100;
parameter CLK_SEMI_PERIOD= 1e3/CLK_FREQ_MHz/2; parameter CLK_SEMI_PERIOD= 1e3/CLK_FREQ_MHz/2;
parameter address_length = 32; parameter address_length = 32;
initial CLK <= 0; initial CLK <= 0;
always begin always begin
#CLK_SEMI_PERIOD CLK = ~CLK; #CLK_SEMI_PERIOD CLK = ~CLK;
if (err_count >= 10) begin if (err_count >= 10) begin
$display("\n\nThe test was stopped due to errors"); $stop(); $display("\n\nThe test was stopped due to errors"); $stop();
end
end end
end
initial begin initial begin
$timeformat (-9, 2, "ns"); $timeformat (-9, 2, "ns");
$display("Test has been started"); $display("Test has been started");
RA1 = 'b1; RA1 = 'b1;
@(posedge CLK);
if (32'hx !== RD1) begin
$display("The register file should not be initialized by the $readmemh function");
err_count = err_count + 1;
end
@(posedge CLK);
DUT.rf_mem[32] = 32'd1;
if(DUT.rf_mem[32]=== 32'd1) begin
$display("invalid memory size");
err_count = err_count + 1;
end
RA1 <= 'b0;
RA2 <= 'b0;
@(posedge CLK);
if( RD1 !== 'b0 ) begin
$display("time = %0t. invalid data when reading at address 0: RD1 = %h", $time, RD1);
err_count = err_count + 1;
end
if( RD2 !== 'b0 ) begin
$display("time = %0t. invalid data when reading at address 0: RD2 = %h", $time, RD2);
err_count = err_count + 1;
end
@(posedge CLK);
WD <= 32'd1;
WA <= '0;
WE <= 1'b1;
@(posedge CLK);
WE <= 'b0;
RA1 <= 'b0;
@(posedge CLK);
if( RD1 !== 'b0 ) begin
$display("time = %0t. invalid data when reading at address 0: RD1 = %h", $time, RD1);
err_count = err_count + 1;
end
@(posedge CLK);
//------initial
CLK <= 'b0;
RA1 <= 'b0;
RA2 <= 'b0;
WA <= 'b0;
WD <= 'b0;
WE <= 'b0;
@(posedge CLK);
//----- reset
for( i = 1; i < address_length; i = i + 1) begin
@(posedge CLK); @(posedge CLK);
if (32'hx !== RD1) begin WA <= i;
$display("The register file should not be initialized by the $readmemh function"); WD <= 'b0;
err_count = err_count + 1;
end
@(posedge CLK);
DUT.rf_mem[32] = 32'd1;
if(DUT.rf_mem[32]=== 32'd1) begin
$display("invalid memory size");
err_count = err_count + 1;
end
RA1 <= 'b0;
RA2 <= 'b0;
@(posedge CLK);
if( RD1 !== 'b0 ) begin
$display("time = %0t. invalid data when reading at address 0: RD1 = %h", $time, RD1);
err_count = err_count + 1;
end
if( RD2 !== 'b0 ) begin
$display("time = %0t. invalid data when reading at address 0: RD2 = %h", $time, RD2);
err_count = err_count + 1;
end
@(posedge CLK);
WD <= 32'd1;
WA <= '0;
WE <= 1'b1;
@(posedge CLK);
WE <= 'b0;
RA1 <= 'b0;
@(posedge CLK);
if( RD1 !== 'b0 ) begin
$display("time = %0t. invalid data when reading at address 0: RD1 = %h", $time, RD1);
err_count = err_count + 1;
end
@(posedge CLK);
//------initial
CLK <= 'b0;
RA1 <= 'b0;
RA2 <= 'b0;
WA <= 'b0;
WD <= 'b0;
WE <= 'b0;
@(posedge CLK);
//----- reset
for( i = 1; i < address_length; i = i + 1) begin
@(posedge CLK);
WA <= i;
WD <= 'b0;
WE <= 'b1;
end
@(posedge CLK);
WA <= 'b0;
WD <= 'b1;
WE <= 'b1; WE <= 'b1;
end
@(posedge CLK);
WA <= 'b0;
WD <= 'b1;
WE <= 'b1;
@(posedge CLK);
WE <= 'b0;
RA2 <= 'b0;
@(posedge CLK);
if( RD2 !== 'b0 )begin
$display("time = %0t. invalid data when reading at address 0: RD2 = %h", $time, RD2);
err_count = err_count + 1;
end
@(posedge CLK);
for( i = 1; i < address_length; i = i + 1) begin
@(posedge CLK); @(posedge CLK);
WE <= 'b0; WA <= i;
RA2 <= 'b0; WD <= $urandom;
WE <= $urandom % 2;
end
@(posedge CLK);
WE <= 'b0;
for( i = 0; i < address_length; i = i + 1) begin
@(posedge CLK); @(posedge CLK);
if( RD2 !== 'b0 )begin RA1 <= i;
$display("time = %0t. invalid data when reading at address 0: RD2 = %h", $time, RD2); RA2 <= address_length - (i + 1);
err_count = err_count + 1; @(posedge CLK);
if(RD1ref !== RD1) begin
$display("time = %0t, address %h, RD1. Invalid data %h, correct data %h", $time, RA1, RD1, RD1ref);
err_count = err_count + 1;
end end
@(posedge CLK); if(RD2ref !== RD2) begin
for( i = 1; i < address_length; i = i + 1) begin $display("time = %0t, address %h, RD2. Invalid data %h, correct data %h", $time, RA2, RD2, RD2ref);
@(posedge CLK); err_count = err_count + 1;
WA <= i;
WD <= $urandom;
WE <= $urandom % 2;
end end
@(posedge CLK); end
WE <= 'b0; $display("\nTest has been finished\nNumber of errors: %d\n", err_count);
for( i = 0; i < address_length; i = i + 1) begin $finish();
@(posedge CLK); #5;
RA1 <= i; $display("You're trying to run simulation that has finished. Aborting simulation.")
RA2 <= address_length - (i + 1); $fatal();
@(posedge CLK);
if(RD1ref !== RD1) begin
$display("time = %0t, address %h, RD1. Invalid data %h, correct data %h", $time, RA1, RD1, RD1ref);
err_count = err_count + 1;
end
if(RD2ref !== RD2) begin
$display("time = %0t, address %h, RD2. Invalid data %h, correct data %h", $time, RA2, RD2, RD2ref);
err_count = err_count + 1;
end
end
if( !err_count ) $display("\nregister file SUCCESS!!!\n");
$finish();
end end
endmodule endmodule

View File

@@ -36,6 +36,9 @@ module lab_04_tb_CYBERcobra();
#10000; #10000;
$display("\n The test is over \n See the internal signals of the CYBERcobra on the waveform \n"); $display("\n The test is over \n See the internal signals of the CYBERcobra on the waveform \n");
$finish; $finish;
#5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end end
endmodule endmodule

View File

@@ -15,7 +15,7 @@ module lab_05_tb_decoder();
typedef class riscv_instr; typedef class riscv_instr;
riscv_instr instr = new(); riscv_instr instr = new();
logic clk, test_has_been_finished; logic clk;
logic [31:0] fetched_instr_i = '0; logic [31:0] fetched_instr_i = '0;
int err_count; int err_count;
@@ -136,8 +136,10 @@ module lab_05_tb_decoder();
illegal_instrs_random_test(); illegal_instrs_random_test();
$display("\nTest has been finished\nNumber of errors: %d\n", err_count); $display("\nTest has been finished\nNumber of errors: %d\n", err_count);
test_has_been_finished = 1'b1;
$finish(); $finish();
#5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end end
function void randomize_with_given_opcode(input logic[4:0] given_opcode); function void randomize_with_given_opcode(input logic[4:0] given_opcode);
@@ -348,17 +350,12 @@ module lab_05_tb_decoder();
bit test_paused_by_errs; bit test_paused_by_errs;
initial begin initial begin
clk = '0; clk = '0;
test_has_been_finished = '0;
err_count = '0; err_count = '0;
test_paused_by_errs = '0; test_paused_by_errs = '0;
end end
always #5 clk = ~clk; always #5 clk = ~clk;
always @(posedge clk) begin
if(test_has_been_finished) begin
$finish();
end
end
always @(posedge clk) begin always @(posedge clk) begin
if((err_count >= 10) & !test_paused_by_errs) begin if((err_count >= 10) & !test_paused_by_errs) begin

View File

@@ -30,8 +30,6 @@ module lab_06_tb_data_mem;
int err_cnt = 0; int err_cnt = 0;
static bit simulation_finished;
data_mem DUT (.*); data_mem DUT (.*);
task read_request(input logic [31:0] address, output logic [31:0] data); task read_request(input logic [31:0] address, output logic [31:0] data);
@@ -173,8 +171,10 @@ module lab_06_tb_data_mem;
random_test(); random_test();
$display("\nTest has been finished\nNumber of errors: %d\n", err_cnt); $display("\nTest has been finished\nNumber of errors: %d\n", err_cnt);
simulation_finished = 1;
$finish; $finish;
#5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end end
logic [31:0] ram_data; logic [31:0] ram_data;
@@ -275,13 +275,6 @@ module lab_06_tb_data_mem;
$display("Error at %t. ram[%d][31:24] is unstable without write request", $time(), $sampled(addr_reg)); $display("Error at %t. ram[%d][31:24] is unstable without write request", $time(), $sampled(addr_reg));
end end
always @(posedge clk_i) begin
if(simulation_finished) begin
$finish;
end
end
always @(posedge clk_i) begin always @(posedge clk_i) begin
if (err_cnt >= 10) begin if (err_cnt >= 10) begin
$display("\nTest has been stopped after 10 errors"); $stop(); $display("\nTest has been stopped after 10 errors"); $stop();

View File

@@ -18,17 +18,20 @@ module lab_07_tb_processor_system();
.rst_i(rst) .rst_i(rst)
); );
initial clk = 0; initial clk = 0;
always #10 clk = ~clk; always #10 clk = ~clk;
initial begin initial begin
$display( "\nTest has been started."); $display( "\nTest has been started.");
rst = 1; rst = 1;
#40; #40;
rst = 0; rst = 0;
#800; #800;
$display("\n The test is over \n See the internal signals of the module on the waveform \n"); $display("\n The test is over \n See the internal signals of the module on the waveform \n");
$finish; $finish;
end #5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end
stall_seq: assert property ( stall_seq: assert property (
@(posedge system.core.clk_i) disable iff ( system.core.rst_i ) @(posedge system.core.clk_i) disable iff ( system.core.rst_i )

View File

@@ -63,6 +63,9 @@ initial begin
repeat(3e3)@(posedge clk_i); repeat(3e3)@(posedge clk_i);
$display("Simulation finished. Number of errors: %d", err_count); $display("Simulation finished. Number of errors: %d", err_count);
$finish(); $finish();
#5;
$display("You're trying to run simulation that has finished. Aborting simulation.")
$fatal();
end end
initial begin initial begin

View File

@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Project Name : Architectures of Processor Systems (APS) lab work * Project Name : Architectures of Processor Systems (APS) lab work
* File : alu_riscv.sv * File : alu.sv
* Organization : National Research University of Electronic Technology (MIET) * Organization : National Research University of Electronic Technology (MIET)
* Department : Institute of Microdevices and Control Systems * Department : Institute of Microdevices and Control Systems
* Author(s) : Alexey Kozin * Author(s) : Alexey Kozin
@@ -10,22 +10,22 @@ See LICENSE file for licensing details.
* ------------------------------------------------------------------------------ * ------------------------------------------------------------------------------
*/ */
parameter ALUOP_W = 5; module alu (
parameter OP_W = 32; input logic [4:0] alu_op_i,
parameter SHIFT_W = $clog2(OP_W); input logic [31:0] a_i,
parameter STAGE_LEN = OP_W+1; input logic [31:0] b_i,
parameter HASH_LEN = 1000; output logic [31:0] result_o,
parameter START_CODING = 10366; output logic flag_o
parameter START_MUX = START_CODING+100;
module alu_riscv (
input logic [ALUOP_W-1:0] alu_op_i,
input logic [OP_W-1:0] a_i,
input logic [OP_W-1:0] b_i,
output logic [OP_W-1:0] result_o,
output logic flag_o
); );
localparam ALUOP_W = 5;
localparam OP_W = 32;
localparam SHIFT_W = $clog2(OP_W);
localparam STAGE_LEN = OP_W+1;
localparam HASH_LEN = 1000;
localparam START_CODING = 10366;
localparam START_MUX = START_CODING+100;
genvar i, j, k; genvar i, j, k;
logic [OP_W-1:0] skjfbsbgisg [0:STAGE_LEN-1]; logic [OP_W-1:0] skjfbsbgisg [0:STAGE_LEN-1];

View File

@@ -1,54 +0,0 @@
/* -----------------------------------------------------------------------------
* Project Name : Architectures of Processor Systems (APS) lab work
* Organization : National Research University of Electronic Technology (MIET)
* Department : Institute of Microdevices and Control Systems
* Author(s) : Nikita Bulavin
* Email(s) : nekkit6@edu.miet.ru
See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details.
* ------------------------------------------------------------------------------
*/
module data_mem (
input logic clk_i,
input logic [31:0] addr_i,
input logic [31:0] write_data_i,
input logic write_enable_i,
input logic mem_req_i,
output logic [31:0] read_data_o
);
`define akjsdnnaskjdndat $clog2(128)
`define cdyfguvhbjnmkdat $clog2(`akjsdnnaskjdndat)
`define qwenklfsaklasddat $clog2(`cdyfguvhbjnmkdat)
`define asdasdhkjasdsadat (34>>`cdyfguvhbjnmkdat)
logic [31:0] RAM [0:4095];
logic [31:0] addr;
assign addr = {20'b0, addr_i[13:2]};
always_ff @(posedge clk_i) begin
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][{5{1'b1}}:{3'd7,2'b00}] <= write_data_i['h1f:'h1c];
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][19:{1'b1,4'h0}] <= write_data_i[42-23-:`asdasdhkjasdsadat];
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][{3{1'b1}}:{1'b1,2'h0}] <= write_data_i[`akjsdnnaskjdndat-:`asdasdhkjasdsadat];
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][23:{{2{2'b10}},1'b0}] <= write_data_i[42-19-:`asdasdhkjasdsadat];
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][27:{2'b11,3'b000}] <= write_data_i['h1b:'h18];
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][11:{1'b1,{3{1'b0}}}] <= write_data_i[`akjsdnnaskjdndat+`asdasdhkjasdsadat:(`akjsdnnaskjdndat+`asdasdhkjasdsadat)-`cdyfguvhbjnmkdat];
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][{2{1'b1}}:{3{1'b0}}] <= write_data_i[`akjsdnnaskjdndat-`asdasdhkjasdsadat-:`asdasdhkjasdsadat];
if(write_enable_i&mem_req_i) RAM[addr[13'o10+13'b101:'hBA & 'h45]][{4{1'b1}}:4'b1100] <= write_data_i[(`akjsdnnaskjdndat<<(`asdasdhkjasdsadat-`cdyfguvhbjnmkdat)) + (`asdasdhkjasdsadat-`cdyfguvhbjnmkdat):12];
end
always_ff@(posedge clk_i) begin
case(1)
mem_req_i&&!write_enable_i: begin
read_data_o['h1f:'h1c]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][{5{1'b1}}:{3'd7,2'b00}];
read_data_o[42-23-:`asdasdhkjasdsadat]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][19:{1'b1,4'h0}];
read_data_o[`akjsdnnaskjdndat-:`asdasdhkjasdsadat]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][{3{1'b1}}:{1'b1,2'h0}];
read_data_o[42-19-:`asdasdhkjasdsadat]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][23:{{2{2'b10}},1'b0}];
read_data_o['h1b:'h18]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][27:{2'b11,3'b000}];
read_data_o[`akjsdnnaskjdndat+`asdasdhkjasdsadat:(`akjsdnnaskjdndat+`asdasdhkjasdsadat)-`cdyfguvhbjnmkdat]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][11:8];
read_data_o[`akjsdnnaskjdndat-`asdasdhkjasdsadat-:`asdasdhkjasdsadat]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][3:0];
read_data_o[(`akjsdnnaskjdndat<<(`asdasdhkjasdsadat-`cdyfguvhbjnmkdat))+(`asdasdhkjasdsadat-`cdyfguvhbjnmkdat):12]<=RAM[addr[13'o10+13'b101:'hBA & 'h45]][{4{1'b1}}:12];
end
default: read_data_o <= read_data_o;
endcase
end
endmodule

View File

@@ -2,8 +2,8 @@
* Project Name : Architectures of Processor Systems (APS) lab work * Project Name : Architectures of Processor Systems (APS) lab work
* Organization : National Research University of Electronic Technology (MIET) * Organization : National Research University of Electronic Technology (MIET)
* Department : Institute of Microdevices and Control Systems * Department : Institute of Microdevices and Control Systems
* Author(s) : Nikita Bulavin * Author(s) : Andrei Solodovnikov
* Email(s) : nekkit6@edu.miet.ru * Email(s) : hepoh@org.miet.ru
See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details. See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details.
* ------------------------------------------------------------------------------ * ------------------------------------------------------------------------------

View File

@@ -8,7 +8,7 @@
See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details. See https://github.com/MPSU/APS/blob/master/LICENSE file for licensing details.
* ------------------------------------------------------------------------------ * ------------------------------------------------------------------------------
*/ */
module rf_riscv( module register_file(
input logic clk_i, input logic clk_i,
input logic write_enable_i, input logic write_enable_i,