rename openriscv to tinyriscv

Signed-off-by: liangkangnan <liangkangnan@163.com>
pull/1/head
liangkangnan 2020-02-23 17:01:45 +08:00
parent 97c7cee0ad
commit 076610fb0d
15 changed files with 80650 additions and 24987 deletions

View File

@ -1,3 +1,19 @@
/*
Copyright 2019 Blue Liang, liangkangnan@163.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
`include "defines.v"
@ -13,7 +29,7 @@ module div (
output reg[`DoubleRegBus] result_o,
output reg ready_o
);
);
parameter STATE_IDLE = 0;
parameter STATE_START = 1;

View File

@ -63,7 +63,7 @@ module ex (
output reg jump_flag_o, // if jump or not flag
output reg[`RegBus] jump_addr_o // jump dest addr
);
);
wire[31:0] sign_extend_tmp;
wire[4:0] shift_bits;

View File

@ -16,7 +16,7 @@
`include "defines.v"
// identify module
// identification module
module id (
input wire clk,
@ -43,7 +43,7 @@ module id (
output reg sram_re_o, // ram read enable
output reg sram_we_o // ram write enable
);
);
wire[6:0] opcode = inst_i[6:0];
wire[2:0] funct3 = inst_i[14:12];

View File

@ -31,7 +31,7 @@ module if_id (
output reg[`SramBus] inst_o,
output reg[`SramAddrBus] inst_addr_o
);
);
always @ (posedge clk) begin
if (rst == `RstEnable) begin

View File

@ -31,7 +31,7 @@ module pc_reg (
output reg[`SramAddrBus] pc_o,
output reg re_o
);
);
reg[`SramAddrBus] offset;

View File

@ -34,10 +34,11 @@ module regs (
input wire[`RegAddrBus] raddr2, // reg2 read addr
output reg[`RegBus] rdata2 // reg2 read data
);
);
reg[`RegBus] regs[0:`RegNum - 1];
// write reg
always @ (posedge clk) begin
if (rst == `RstDisable) begin
if((we == `WriteEnable) && (waddr != `RegNumLog2'h0)) begin
@ -46,6 +47,7 @@ module regs (
end
end
// read reg1
always @ (*) begin
if(rst == `RstEnable) begin
rdata1 <= `ZeroWord;
@ -58,6 +60,7 @@ module regs (
end
end
// read reg2
always @ (*) begin
if(rst == `RstEnable) begin
rdata2 <= `ZeroWord;

View File

@ -34,10 +34,11 @@ module sim_ram (
input wire[`SramAddrBus] ex_raddr_i, // ex read addr
output reg[`SramBus] ex_rdata_o // ex read data
);
);
reg[`SramBus] ram[0:`SramMemNum - 1];
// write mem
always @ (posedge clk) begin
if (rst == `RstDisable) begin
if(we_i == `WriteEnable) begin
@ -46,6 +47,7 @@ module sim_ram (
end
end
// read inst
always @ (*) begin
if(rst == `RstEnable) begin
pc_rdata_o <= `ZeroWord;
@ -58,6 +60,7 @@ module sim_ram (
end
end
// read mem
always @ (*) begin
if(rst == `RstEnable) begin
ex_rdata_o <= `ZeroWord;

View File

@ -16,13 +16,13 @@
`include "defines.v"
// CPU core module
module openriscv_core (
// CPU core top module
module tinyriscv_core (
input wire clk,
input wire rst
);
);
// pc_reg
wire[`SramAddrBus] pc_pc_o;

View File

@ -1,354 +1,52 @@
10000113
00000d13
00000d93
00000093
00000113
00208f33
00000e93
00200193
4ddf1663
00100093
00100113
00208f33
00200e93
00300193
4bdf1a63
00300093
00700113
00208f33
00a00e93
00400193
49df1e63
00000093
ffff8137
00208f33
ffff8eb7
00500193
49df1263
800000b7
00000113
00208f33
80000eb7
00600193
47df1663
800000b7
ffff8137
00208f33
7fff8eb7
00700193
45df1a63
00000093
00008137
fff10113
00208f33
00008eb7
fffe8e93
00800193
43df1a63
800000b7
fff08093
00000113
00208f33
80000eb7
fffe8e93
00900193
41df1a63
800000b7
fff08093
00008137
fff10113
00208f33
80008eb7
ffee8e93
00a00193
3fdf1863
800000b7
00008137
fff10113
00208f33
80008eb7
fffe8e93
00b00193
3ddf1863
800000b7
fff08093
ffff8137
00208f33
7fff8eb7
fffe8e93
00c00193
3bdf1863
00000093
fff00113
00208f33
fff00e93
00d00193
39df1c63
fff00093
00100113
00208f33
00000e93
00e00193
39df1063
fff00093
fff00113
00208f33
ffe00e93
00f00193
37df1463
00100093
80000137
fff10113
00208f33
80000eb7
01000193
35df1663
00d00093
00b00113
002080b3
01800e93
01100193
33d09a63
00e00093
00b00113
00208133
01900e93
01200193
31d11e63
00d00093
001080b3
01a00e93
01300193
31d09463
00000213
00d00093
00b00113
00208f33
000f0313
00120213
00200293
fe5214e3
01800e93
01400193
2dd31e63
00000213
00e00093
00b00113
00208f33
00000013
000f0313
00120213
00200293
fe5212e3
01900e93
01500193
2bd31663
00000213
00f00093
00b00113
00208f33
00000013
00000013
000f0313
00120213
00200293
fe5210e3
01a00e93
01600193
27d31c63
00000213
00d00093
00b00113
00208f33
00120213
00200293
fe5216e3
01800e93
01700193
25df1863
00000213
00e00093
00b00113
00000013
00208f33
00120213
00200293
fe5214e3
01900e93
01800193
23df1263
00000213
00f00093
00b00113
00000013
00000013
00208f33
00120213
00200293
fe5212e3
01a00e93
01900193
1fdf1a63
00000213
00d00093
00000013
00b00113
00208f33
00120213
00200293
fe5214e3
01800e93
01a00193
1ddf1463
00000213
00e00093
00000013
00b00113
00000013
00208f33
00120213
00200293
fe5212e3
01900e93
01b00193
19df1c63
00000213
00f00093
00000013
00000013
00b00113
00208f33
00120213
00200293
fe5212e3
01a00e93
01c00193
17df1463
00000213
00b00113
00d00093
00208f33
00120213
00200293
fe5216e3
01800e93
01d00193
15df1063
00000213
00b00113
00e00093
00000013
00208f33
00120213
00200293
fe5214e3
01900e93
01e00193
11df1a63
00000213
00b00113
00f00093
00000013
00000013
00208f33
00120213
00200293
fe5212e3
01a00e93
01f00193
0fdf1263
00000213
00b00113
00000013
00d00093
00208f33
00120213
00200293
fe5214e3
01800e93
02000193
0bdf1c63
00000213
00b00113
00000013
00e00093
00000013
00208f33
00120213
00200293
fe5212e3
01900e93
02100193
09df1463
00000213
00b00113
00000013
00000013
00f00093
00208f33
00120213
00200293
fe5212e3
01a00e93
02200193
05df1c63
00f00093
00100133
00f00e93
02300193
05d11263
02000093
00008133
02000e93
02400193
03d11863
000000b3
00000e93
02500193
03d09063
01000093
01e00113
00208033
00000e93
02600193
01d01463
00301863
04c000ef
00100d13
00000d93
0000006f
00100d13
ff010113
00812623
01010413
00100d93
0000006f
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000013
00c12403
01010113
00008067
ff010113
00812623
01010413
00000d93
00000013
00c12403
01010113
00008067
fe010113
00112e23
00812c23
02010413
fe042423
fe042623
0200006f
fe842703
fec42783
00f707b3
fef42423
fec42783
00178793
fef42623
fec42703
06400793
fce7dee3
fe842703
000017b7
3ba78793
00f71663
f6dff0ef
0080006f
f85ff0ef
00000793
00078513
01c12083
01812403
02010113
00008067

File diff suppressed because it is too large Load Diff

12020
sim/out.vvp

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
iverilog -s openriscv_core_tb -o out.vvp -I ..\rtl openriscv_core_tb.v ..\rtl\defines.v ..\rtl\ex.v ..\rtl\id.v ..\rtl\openriscv_core.v ..\rtl\pc_reg.v ..\rtl\regs.v ..\rtl\sim_ram.v ..\rtl\if_id.v ..\rtl\div.v
iverilog -s tinyriscv_core_tb -o out.vvp -I ..\rtl tinyriscv_core_tb.v ..\rtl\defines.v ..\rtl\ex.v ..\rtl\id.v ..\rtl\tinyriscv_core.v ..\rtl\pc_reg.v ..\rtl\regs.v ..\rtl\sim_ram.v ..\rtl\if_id.v ..\rtl\div.v
vvp out.vvp

View File

@ -1,3 +1,3 @@
..\tools\BinToMem_CLI.exe %1 %2
iverilog -s openriscv_core_tb -o out.vvp -I ..\rtl openriscv_core_tb.v ..\rtl\defines.v ..\rtl\ex.v ..\rtl\id.v ..\rtl\openriscv_core.v ..\rtl\pc_reg.v ..\rtl\regs.v ..\rtl\sim_ram.v ..\rtl\if_id.v ..\rtl\div.v
iverilog -s tinyriscv_core_tb -o out.vvp -I ..\rtl tinyriscv_core_tb.v ..\rtl\defines.v ..\rtl\ex.v ..\rtl\id.v ..\rtl\tinyriscv_core.v ..\rtl\pc_reg.v ..\rtl\regs.v ..\rtl\sim_ram.v ..\rtl\if_id.v ..\rtl\div.v
vvp out.vvp

View File

@ -2,17 +2,17 @@
`include "defines.v"
// top module
module openriscv_core_tb;
// testbench module
module tinyriscv_core_tb;
reg clk;
reg rst;
always #10 clk = ~clk; // 50MHz
wire[`RegBus] x3 = u_openriscv_core.u_regs.regs[3];
wire[`RegBus] x26 = u_openriscv_core.u_regs.regs[26];
wire[`RegBus] x27 = u_openriscv_core.u_regs.regs[27];
wire[`RegBus] x3 = u_tinyriscv_core.u_regs.regs[3];
wire[`RegBus] x26 = u_tinyriscv_core.u_regs.regs[26];
wire[`RegBus] x27 = u_tinyriscv_core.u_regs.regs[27];
integer r;
initial begin
@ -46,7 +46,7 @@ module openriscv_core_tb;
$display("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
$display("fail testnum = %2d", x3);
for (r = 0; r < 32; r++)
$display("x%2d = 0x%x", r, u_openriscv_core.u_regs.regs[r]);
$display("x%2d = 0x%x", r, u_tinyriscv_core.u_regs.regs[r]);
end
$finish;
end
@ -60,16 +60,16 @@ module openriscv_core_tb;
// read mem data
initial begin
$readmemh ("inst.data", u_openriscv_core.u_sim_ram.ram);
$readmemh ("inst.data", u_tinyriscv_core.u_sim_ram.ram);
end
// generate wave file, use by gtkwave
// generate wave file, used by gtkwave
initial begin
$dumpfile("openriscv_core_tb.vcd");
$dumpvars(0, openriscv_core_tb);
$dumpfile("tinyriscv_core_tb.vcd");
$dumpvars(0, tinyriscv_core_tb);
end
openriscv_core u_openriscv_core(
tinyriscv_core u_tinyriscv_core (
.clk(clk),
.rst(rst)
);

74096
sim/tinyriscv_core_tb.vcd Normal file

File diff suppressed because it is too large Load Diff