Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
9164c21
git ignore added
Jrvvv Sep 12, 2023
fc94b84
constraint added
Jrvvv Sep 13, 2023
5ae488f
done but not tested
Jrvvv Sep 14, 2023
b99c751
git ignore sv added and .sv pushed
Jrvvv Sep 14, 2023
c9d448e
minor
Jrvvv Sep 14, 2023
be6666c
ALU done not tested
Jrvvv Sep 14, 2023
7e3d30a
ALU done not tested
Jrvvv Sep 14, 2023
53b5b45
dynamic indication added
Jrvvv Sep 26, 2023
f7a1975
logs configs and etc deleted
Jrvvv Sep 26, 2023
c664b84
logs configs and etc deleted
Jrvvv Sep 26, 2023
11e7bfa
logs configs and etc deleted
Jrvvv Sep 26, 2023
ed8e084
simple tb added for ALU
Jrvvv Sep 27, 2023
7739e1e
ALU minor changes + board file
Jrvvv Sep 28, 2023
c91d06d
instr mem done and init file uploaded
Jrvvv Oct 10, 2023
d69e81b
tb added + minor changes
Jrvvv Oct 10, 2023
fe0fcd8
data mem is not full done
Jrvvv Oct 10, 2023
6578113
all memory types done and tested
Jrvvv Oct 10, 2023
7b071a2
board file added
Jrvvv Oct 10, 2023
90184f6
ignore changed txt added
Jrvvv Oct 11, 2023
bd39810
raw cobra module, tb and board + example prog
Jrvvv Oct 11, 2023
7246b6e
proj file chenged
Jrvvv Oct 11, 2023
de325f7
cobra done but no custom program
Jrvvv Oct 11, 2023
7c0b5c5
example prog added in proj and instr mem module
Jrvvv Oct 11, 2023
b8956f6
cobra done and programs written
Jrvvv Oct 12, 2023
fd3aba6
cobra done and programs written
Jrvvv Oct 12, 2023
5403d0b
git ignore cpp exception added
Jrvvv Oct 12, 2023
0cffa6f
cobra cinverter added
Jrvvv Oct 12, 2023
a0f6bc8
my cobra prog fixed and tested
Jrvvv Oct 12, 2023
97725f5
rf file name change
Jrvvv Oct 13, 2023
2bf20a2
Update README.md
Jrvvv Oct 20, 2023
a9fce84
board file for my prog added
Jrvvv Oct 24, 2023
9646c3f
added board file for my prog in proj
Jrvvv Oct 24, 2023
0ac720e
looped example of prog done and tested
Jrvvv Oct 24, 2023
7375b33
proj config changed and minor changes in borad file
Jrvvv Oct 24, 2023
0e8b8e2
decoder added, tb moved to separated dir, proj reconfig
Jrvvv Oct 26, 2023
8d7a1e9
prototype with cases written
Jrvvv Nov 2, 2023
66f45dc
added partly funct3/7 cases
Jrvvv Nov 2, 2023
e10ee59
all cases done, TODO: add out signals
Jrvvv Nov 2, 2023
9188710
R S and I instr types done
Jrvvv Nov 2, 2023
3eb1fb1
full done not tested
Jrvvv Nov 2, 2023
0f952db
decoder done
Jrvvv Nov 3, 2023
4c6f358
datapath(dp) raw sv files, prog txt file, dp board file added to proj…
Jrvvv Nov 7, 2023
3f11dd5
risc v core partly done
Jrvvv Nov 7, 2023
2981e1c
risc v core partly done
Jrvvv Nov 7, 2023
b23075b
core module done
Jrvvv Nov 7, 2023
122c9dd
core tested with tb and working well
Jrvvv Nov 7, 2023
6b5781c
swap bytes prog written and tested
Jrvvv Nov 8, 2023
d2aafa7
asm program changed and board file with data output added
Jrvvv Nov 9, 2023
ba21376
exter mem done, raw lsu and tb for lsu
Jrvvv Nov 21, 2023
08dab54
minor changes in exter mem + raw lsu
Jrvvv Nov 21, 2023
a2e02c2
exter mem done with ternar
Jrvvv Nov 21, 2023
9ef5f05
in cpu unit ext_mem instaed of data_mem, LSU prototype done + disable…
Jrvvv Nov 21, 2023
c43fc06
project structure changed
Jrvvv Nov 21, 2023
cd38be8
project structure changed
Jrvvv Nov 21, 2023
c5621b5
lsu done not tested
Jrvvv Nov 21, 2023
87f2ae6
lsu error fixed
Jrvvv Nov 21, 2023
548f283
wafeform enabled for repo
Jrvvv Nov 21, 2023
fbaa539
wafeform for test ls funcs added
Jrvvv Nov 21, 2023
72e3929
minor fixes in connection
Jrvvv Nov 21, 2023
5b1c672
programs for ls testing
Jrvvv Nov 21, 2023
09bad30
tests for unit with LSU done and all OK
Jrvvv Nov 21, 2023
83719dc
minor changes
Jrvvv Dec 7, 2023
41eec2c
sync rst added
Jrvvv Dec 7, 2023
9a2f867
csr controller done and ok
Jrvvv Dec 7, 2023
7ef413e
irq cntrlr partly done
Jrvvv Dec 7, 2023
dc42db2
interrupt controler done and is working well
Jrvvv Dec 10, 2023
45d34bb
new gitignore
Jrvvv Dec 16, 2023
0814d49
interrupt subsystem integrated + tb loaded + bin prog added in instr mem
Jrvvv Dec 16, 2023
8a52363
irq wires in unit module added
Jrvvv Dec 16, 2023
ad4ab20
bug with PC fixed (err in decoder)
Jrvvv Dec 16, 2023
fb69517
wf minor changes + fixed wire length on core
Jrvvv Dec 17, 2023
fdde8ee
wb sel wire width fixed, all done, working well
Jrvvv Dec 17, 2023
0814809
soft/tb/module files for peripheral from repo added
Jrvvv Dec 17, 2023
97c8d90
added files to project
Jrvvv Dec 17, 2023
564ac22
minor changes
Jrvvv Dec 17, 2023
0e74148
minor changes
Jrvvv Dec 17, 2023
59593b1
unit module changed for peripherial dev
Jrvvv Dec 19, 2023
b5c0eef
partly done ps/2
Jrvvv Dec 21, 2023
9d3b753
ignore update
Jrvvv Dec 28, 2023
95f578c
mem file for vga added
Jrvvv Dec 28, 2023
bb255d2
mem files with bin instrs all changed in proj
Jrvvv Dec 28, 2023
87bd72e
modules ps2 and vga written not tested
Jrvvv Dec 28, 2023
5434d7d
minor style changes
Jrvvv Dec 28, 2023
2837496
not finished cpu unit for peripherial
Jrvvv Dec 28, 2023
07fc8f7
finished but not checked errors
Jrvvv Dec 28, 2023
aa8626b
added new waveform for peripheral unit module tb
Jrvvv Dec 29, 2023
7acd06c
vga module with w/r reqs + waveform minor changes
Jrvvv Dec 29, 2023
d1712aa
constraint changed for peripheral (cpu unit as top)
Jrvvv Dec 30, 2023
172b401
new ignore ld added
Jrvvv Jan 18, 2024
92b9ca5
startup and ld added
Jrvvv Jan 18, 2024
9d55b45
sh files added
Jrvvv Jan 18, 2024
84a128b
simple prog + script to compile, link, mem convert
Jrvvv Jan 18, 2024
678f9a6
init mem files added to project and in sv files data mem and instr mem
Jrvvv Jan 19, 2024
bedb517
info abour sp (dor current version) added to startup
Jrvvv Jan 19, 2024
4888ba5
minor changes in code, added function to init full screen with 1 char…
Jrvvv Jan 19, 2024
233ee9a
mem minor changes + wf update and project config
Jrvvv Jan 19, 2024
fd0b4f4
constraints update
Jrvvv Jan 19, 2024
41671b2
color scheme changed, linker file gp value changed
Jrvvv Jan 19, 2024
c3e9ff4
orig linker and variative script
Jrvvv Jan 19, 2024
7ccc383
loops to while changed
Jrvvv Jan 19, 2024
5533edf
const to uint8_t
Jrvvv Jan 19, 2024
11d620e
minor changes
Jrvvv Jan 20, 2024
377e668
minor changes
Jrvvv Jan 20, 2024
9f834e6
ext mem module romoved magic numbers, changes in code for LR13 -- int…
Jrvvv Jan 23, 2024
fd3e6e2
new detailed wf, minor changes in .h and instr mem address range changed
Jrvvv Jan 24, 2024
138a31d
new wf
Jrvvv Jan 24, 2024
8f48962
minor changes in ext mem (width addr err)
Jrvvv Jan 24, 2024
0cfc109
my ld file working
Jrvvv Jan 24, 2024
e3466be
MAJOR ERROR FIXED IN BYTE ENABLE CHOOSING
Jrvvv Jan 24, 2024
53da969
working version of software part
Jrvvv Jan 24, 2024
908da6b
last used wf for debugging
Jrvvv Jan 24, 2024
72d24a8
minor changes
Jrvvv Jan 24, 2024
ad066ba
Update README.md
Jrvvv Jan 26, 2024
7f20d3d
Update README.md
Jrvvv Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#########################################################################################################
## This is an example .gitignore file for Vivado, please treat it as an example as
## it might not be complete. In addition, XAPP 1165 should be followed.
#########################################################################################################
#########
#Exclude all
#########
*
!*/
!.gitignore
###########################################################################
## VIVADO
###########################################################################
#########
#Source files:
#########
#Do NOT ignore VHDL, Verilog, block diagrams or EDIF files.
!*.vhd
!*.v
!*.sv
# !*.bd
# !*.edif
#########
#IP files
#########
#.xci: synthesis and implemented not possible - you need to return back to the previous version to generate output products
#.xci + .dcp: implementation possible but not re-synthesis
#*.xci(www.spiritconsortium.org)
# !*.xci
#*.dcp(checkpoint files)
# !*.dcp
# !*.vds
!*.pb
#All bd comments and layout coordinates are stored within .ui
!*.ui
!*.ooc
#########
#System Generator
#########
# !*.mdl
# !*.slx
# !*.bxml
#########
#Simulation logic analyzer
#########
!*.wcfg
# !*.coe
#########
#MIG
#########
# !*.prj
# !*.mem
#########
#Project files
#########
#XPR + *.XML ? XPR (Files are merged into a single XPR file for 2014.1 version)
#Do NOT ignore *.xpr files
!*.xpr
#Include *.xml files for 2013.4 or earlier version
# !*.xml
#########
#Constraint files
#########
#Do NOT ignore *.xdc files
!*.xdc
#########
#TCL - files
#########
!*.tcl
#########
#Journal - files
#########
# !*.jou
#########
#Reports
#########
# !*.rpt
!*.txt
# !*.vdi
#########
#C-files
#########
!*.cpp
!*.c
!*.h
!*.elf
!*.S
!*.mem
!*.ld
!*.sh
# !*.bmm
# !*.xmp
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# APSLabs
Developing RISC-V CPU
# Simple RISC-V CPU development
Architectures of processor systems, developing simple RISC-V CPU.

Testbanches, and board files are partly taken from [this course](https://github.com/MPSU/APS/tree/master/Labs).
211 changes: 211 additions & 0 deletions constraints/nexys_a7_100t.xdc

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions other/COBRAconverter/conv.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include <fstream>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>

void print_help(const std::string program_name)
{
using namespace std;
cout << "Usage: " << program_name << " [input file] [output file]\n\n";
cout << "Convert CYBERcobra program file into $readmemh acceptable file.\n";
cout << "CYBERcobra program file may contain only comments (starting with \"//\"),\n";
cout << "whitespaces and binary digits '0' or '1'.\n";
cout << "This program will erase this parts from every line and then convert\n";
cout << "in hex-format.\n\n";
cout << "If output file omitted, the <input_file_base>_converted.<input_file_ext>\n";
cout << "will be produced.\n\n";
cout << "If input file omitted, program.txt will be used.\n\n";
cout << "Example:\n\n";
cout << program_name << " open \"program.txt\" and produce \"program_converted.txt\"\n";
cout << program_name << " test.txt open \"test.txt\" and produce \"test_converted.txt\"\n";
cout << program_name << " test.txt myname.dat open \"test.txt\" and produce \"myname.dat\"\n";

}

int main(int argc, char ** argv)
{
using namespace std;
/*
Parse argument list and print help message if needed
*/
string ifname;
string ofname;
string start;
string end;
string filename = argv[0];
size_t dot_pos;
filename = filename.substr(filename.find_last_of("/\\") + 1);
switch (argc)
{
case 1:
ifname = "program.txt";
ofname = "program_converted.txt";
break;
case 2:
if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))
{
print_help(filename);
return 0;
}
ifname = argv[1];
dot_pos = ifname.find(".");
if(dot_pos != string::npos)
{
start = ifname.substr(0, dot_pos);
end = ifname.substr(dot_pos, ifname.size() - dot_pos);
ofname = start + "_converted" + end;
}
else
{
ofname = ifname + "_converted";
}
break;
case 3:
ifname = argv[1];
ofname = argv[2];
break;
default:
print_help(filename);
return 0;
}


/*
Program body
*/
// Open input and output files
ifstream ifs(ifname);
if(!ifs)
{
cerr << "Unable to open file: \"" << ifname << "\"" << endl;
return -1;
}
ofstream ofs(ofname);

if (!ofs.is_open())
{
cerr << "Unable to open file: \"" << ofname << "\"" << endl;
return -1;
}
string str;
size_t line_counter = 0;
while (getline(ifs, str))
{
line_counter++;
// trim line from comments and whitespaces, skip empty lines after trimming
auto comment_pos = str.find("//");
if(comment_pos != string::npos)
{
str.erase(comment_pos);
}
str.erase(remove_if(str.begin(), str.end(), ::isspace), str.end());
if(!str.size())
{
continue;
}
if(str.size()!=32)
{
cerr << "line " << line_counter << " length is not equal 32 after trimming comments and whitespaces" << endl;
return -2;
}
// Convert into hex lines and write them into file
size_t valid_char_num;
uint32_t cur_word = std::stoll(str, &valid_char_num, 2);
if(valid_char_num != 32)
{
cerr << "Illegal character '" << str.at(valid_char_num) <<
"' found in line " << line_counter << ": \"" << str << "\"\n";
cerr << "Should be only '0' or '1'." << endl;
return -3;
}
char hex_byte_str[9];
// convert int representation into hex string
snprintf(hex_byte_str, 9, "%08x", cur_word);
ofs << hex_byte_str << "\n";
}
ifs.close();
ofs.close();

return 0;
}
33 changes: 33 additions & 0 deletions other/dyn_ind/HEX.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
`timescale 1ns / 1ps

module HEX(
input CLK100MHZ,
input [15:0] SW,
output [7:0] AN,
output [6:0] HEX
);

reg [9:0] cntr;
wire isMax;

initial begin
cntr = 10'b0;
end

always@(posedge CLK100MHZ) begin
cntr = cntr + 1'b1;
end

assign isMax = (cntr[9] == 1'b1);

dyn_ind(
isMax,
SW[3:0],
SW[7:4],
SW[11:8],
SW[15:12],
HEX[6:0],
AN[7:0]
);

endmodule
70 changes: 70 additions & 0 deletions other/dyn_ind/dyn_ind.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
`timescale 1ns / 1ps

module dyn_ind
#(parameter WIDTH = 8)
(
input clk,
input [3:0] to_dec0,
input [3:0] to_dec1,
input [3:0] to_dec2,
input [3:0] to_dec3,
output reg [6:0] to_hex,
output reg [WIDTH-1:0] to_hex_ans
);

reg [2:0] state;
reg [3:0] to_decoder;
wire [6:0] hex_dig;

localparam DIG1 = 3'd0;
localparam DIG2 = 3'd1;
localparam DIG3 = 3'd2;
localparam DIG4 = 3'd3;

initial begin
state = DIG1;
to_decoder = 4'b0;
end

hex_decoder inst1(
to_decoder,
hex_dig
);

always@(posedge clk) begin
case(state)
DIG1:
begin
to_decoder = to_dec0;
to_hex_ans = 8'b11111110;
to_hex = hex_dig;
state = DIG2;
end

DIG2:
begin
to_decoder = to_dec1;
to_hex_ans = 8'b11111101;
to_hex = hex_dig ;
state = DIG3;
end

DIG3:
begin
to_decoder = to_dec2;
to_hex_ans = 8'b11111011;
to_hex = hex_dig ;
state = DIG4;
end

DIG4:
begin
to_decoder = to_dec3;
to_hex_ans = 8'b11110111;
to_hex = hex_dig ;
state = DIG1;
end
endcase
end

endmodule
25 changes: 25 additions & 0 deletions other/dyn_ind/hex_decoder.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
`timescale 1ns / 1ps

module hex_decoder(
input [3:0] to_dec,
output reg [6:0] to_hex
);

always@* begin
case(to_dec)
4'b0000: to_hex = 7'b1000000;
4'b0001: to_hex = 7'b1111001;
4'b0010: to_hex = 7'b0100100;
4'b0011: to_hex = 7'b0110000;
4'b0100: to_hex = 7'b0011001;
4'b0101: to_hex = 7'b0010010;
4'b0110: to_hex = 7'b0000010;
4'b0111: to_hex = 7'b1111000;
4'b1000: to_hex = 7'b0000000;
4'b1001: to_hex = 7'b0010000;
default: to_hex = 7'b1111111;
endcase
end


endmodule
28 changes: 28 additions & 0 deletions riscv_cpu/ALU/alu_opcodes_pkg.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package alu_opcodes_pkg;
parameter ALU_OP_WIDTH = 5;

parameter ALU_ADD = 5'b00000;
parameter ALU_SUB = 5'b01000;

parameter ALU_XOR = 5'b00100;
parameter ALU_OR = 5'b00110;
parameter ALU_AND = 5'b00111;

// shifts
parameter ALU_SRA = 5'b01101;
parameter ALU_SRL = 5'b00101;
parameter ALU_SLL = 5'b00001;

// comparisons
parameter ALU_LTS = 5'b11100;
parameter ALU_LTU = 5'b11110;
parameter ALU_GES = 5'b11101;
parameter ALU_GEU = 5'b11111;
parameter ALU_EQ = 5'b11000;
parameter ALU_NE = 5'b11001;

// set lower than operations
parameter ALU_SLTS = 5'b00010;
parameter ALU_SLTU = 5'b00011;

endpackage
Loading