generated from open-education-hub/oer-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: VPL guide, VPL test 1 * feat: homework FPU * feat: add FPU assigment on VPL * feat: add page for evaluation
- Loading branch information
Showing
74 changed files
with
668 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,26 +2,47 @@ | |
FROM ubuntu:22.04 | ||
|
||
LABEL maintainer="[email protected]" | ||
LABEL version="0.1" | ||
LABEL version="0.2" | ||
LABEL description="The open source toolchain docker image for the Computer Architecture course" | ||
|
||
# for apt-get | ||
# https://serverfault.com/questions/949991/how-to-install-tzdata-on-a-ubuntu-docker-image | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Europe/Bucharest | ||
|
||
# Update Ubuntu Software repository | ||
# https://stackoverflow.com/questions/39760663/docker-ubuntu-bin-sh-1-locale-gen-not-found | ||
# https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue/229512#229512 | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y nano git unzip wget gedit make gcc g++ | ||
apt-get install -y locales && \ | ||
locale-gen "en_US.UTF-8" && \ | ||
dpkg-reconfigure locales | ||
|
||
# install basic tools | ||
RUN apt-get install -y curl sudo zip unzip wget git make gcc g++ nano | ||
|
||
# intall texlive-full | ||
RUN apt-get install -y texlive-full dvipng cm-super | ||
|
||
# install gtkwave through apt-get | ||
# https://github.com/gtkwave/gtkwave | ||
RUN apt-get install -y gtkwave | ||
|
||
# RUN apt-get install -y gtkwave | ||
# install icaurs | ||
# https://github.com/steveicarus/iverilog | ||
RUN apt-get install -y iverilog | ||
|
||
# RUN apt-get install -y iverilog | ||
# install yosys | ||
RUN apt-get install -y yosys | ||
# RUN apt-get install -y yosys | ||
# install verilator | ||
RUN apt-get install -y verilator | ||
# RUN apt-get install -y verilator | ||
RUN apt-get install -y iverilog yosys verilator gtkwave | ||
|
||
# install python3 and pip3 for Pygments | ||
RUN apt-get install -y python3 python3-pip && \ | ||
pip3 install Pygments | ||
|
||
# install java and graphviz | ||
# RUN apt-get install -y openjdk-19-jre graphviz | ||
|
||
# install C/C++ development tools | ||
# RUN apt-get install -y build-essential gdb clang-format |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# ALU | ||
Implementați un ALU. | ||
|
||
Intările ALU sunt: | ||
- i_w_op1 - primul operand (4 biți) | ||
- i_w_op2 - al doilea operand (4 biți) | ||
- i_w_opsel - operația selectată pentru a fi executată de către ALU (2 biți) | ||
|
||
Ieșirea ALU este: | ||
- o_w_out - rezultatul operației între cei doi operanzi (4 biți) | ||
|
||
Apăsați butonul "evaluate" din VPL pentru a afla operațile pe care trebuie sa le implementați pentru fiecare valoare a intrării i_w_opsel. | ||
|
||
Operatiile posibile sunt: | ||
- ADDITION - Adunare între cei doi operanzi | ||
- SUBTRACTION - Scaderea celui de al doilea operand din primul operand | ||
- MULTIPLY - Înmulțirea celor doi operanzi și reținerea în rezultat a celor mai puți semnificativi 4 biți | ||
- DIVIDE - Împărțirea primului operand de către al doilea operand | ||
- MODULUS - Restul împărțirii primului operand de către al doilea operand | ||
- LEFT_SHIFT - Shiftarea la stânga a primului operand cu valoarea celui de al doilea operand | ||
- RIGHT_SHIFT - Shiftarea la dreapta a primului operand cu valoarea celui de al doilea operand | ||
- ARITHMETIC_RIGHT_SHIFT -Shiftarea aritmetică la dreapta a primului operand cu valoarea celui de al doilea operand | ||
- BITWISE_NAND - ȘI-NU între biți celor doi operanzi pe aceleași poziții | ||
- BITWISE_NOR - SAU_NU între biți celor doi operanzi pe aceleași poziții | ||
- BITWISE_AND - ȘI între biți celor doi operanzi pe aceleași poziții | ||
- BITWISE_OR - SAU între biți celor doi operanzi pe aceleași poziții | ||
- BITWISE_XOR - SAU-EXCLUSIV între biți celor doi operanzi pe aceleași poziții | ||
- COMPARE_EQUAL - Dacă cei doi operazi sunt egali rezultatul va avea valoarea 4'd1 astfel 4'd0. | ||
- COMPARE_LESS_THAN - Dacă primul operand este mai mic ca al doilea operand rezultatul va avea valoarea 4'd1 astfel 4'd0. | ||
- COMPARE_GREATER_THAN - Dacă primul operand este mai mare ca al doilea operand rezultatul va avea valoarea 4'd1 astfel 4'd0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# True Table | ||
|
||
Implmentați modulul verilog pentru tabelul de adevăr dat. | ||
|
||
Veți avea 3 intrări: | ||
- i_w_a | ||
- i_w_b | ||
- i_w_c | ||
|
||
Veți avea o singură ieșire: | ||
- o_w_out | ||
|
||
Apăsați butonul "evaluate" din VPL pentru a afla tabelul de adevăr pe care trebuie să îl implementați. | ||
|
||
Exemplu de tabel: | ||
|
||
| i_w_a | i_w_b | i_w_c | o_w_out | | ||
|-------|-------|-------|---------| | ||
| 0 | 0 | 0 | 1 | | ||
| 0 | 0 | 1 | 1 | | ||
| 0 | 1 | 0 | 1 | | ||
| 0 | 1 | 1 | 0 | | ||
| 1 | 0 | 0 | 0 | | ||
| 1 | 0 | 1 | 0 | | ||
| 1 | 1 | 0 | 0 | | ||
| 1 | 1 | 1 | 0 | |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 7-LED Segment DIGIT | ||
Implementați un modul verilog care să afișeze in funcție de o intrare de selecție una din cele 4 cifre date (XYZT). | ||
|
||
Intrările modulului sunt: | ||
- i_w_sel - ce cifră se va afișa (2 biți) | ||
|
||
Ieșirele modulului sunt: | ||
- o_w_ca - linia ca din 7-led segment | ||
- o_w_cb - linia cb din 7-led segment | ||
- o_w_cc - linia cc din 7-led segment | ||
- o_w_cd - linia cd din 7-led segment | ||
- o_w_ce - linia ce din 7-led segment | ||
- o_w_cf - linia cf din 7-led segment | ||
- o_w_cg - linia cg din 7-led segment | ||
|
||
Ca sa aflați cele 4 cifre XYZT apăsați butonul "evaluate" din VPL. | ||
|
||
Pentru valorile i_w_sel: | ||
- i_w_sel = 2'd0, se va afișa cifra T | ||
- i_w_sel = 2'd1, se va afișa cifra Z | ||
- i_w_sel = 2'd2, se va afișa cifra Y | ||
- i_w_sel = 2'd3, se va afișa cifra X | ||
|
||
Avem un 7-led segment cu anod comun și ieșirele vor fi active când vor avea valoarea 1'b0. | ||
|
||
Mai jos puteți vedea cum sunt poziționate linile cx ale 7-led segment. | ||
|
||
![7-LED-SEGMENT](media/led7.jpg) | ||
|
||
Mai jos puteți vedea cum sunt afișate cifrele zecimale pe un 7-led segment. | ||
|
||
![7-LED-DIGITS](media/7leddigits.png) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
variation=$(date +"%d%H") | ||
# make sure variation is a number | ||
variation=$(expr $variation + 0) | ||
# variation will be the same for 2 consecutive hours | ||
if [ $((variation % 2)) == 0 ]; then | ||
variation=variation | ||
else | ||
variation=$(expr $variation - 1) | ||
fi | ||
|
||
echo $variation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.vvp | ||
*.vcd | ||
vpl_execution | ||
fpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
COMPILER=iverilog | ||
INTERPRETER=vvp | ||
FLAGS=-Wall -Winfloop | ||
TOP_MODULE=fpu | ||
TOP_SIM_MODULE=test_${TOP_MODULE} | ||
TOP_EVALUATE_MODULE=evaluate_${TOP_MODULE} | ||
OTHER_SOURCES= | ||
RESULT_FILE=result.out | ||
EVALUATE_FILE=evaluate.out | ||
GRADE_SCRIPT=grade.sh | ||
EVALUATE_FLAGS=+INPUT_FILE=$(RESULT_FILE) | ||
GENERATOR_COMPILER=g++ -std=c++20 | ||
GENERATOR_SOURCE=fpu.cpp | ||
GENERATOR_BINARY=fpu | ||
|
||
all: build | ||
|
||
build: | ||
$(COMPILER) $(FLAGS) $(TOP_MODULE).v $(TOP_SIM_MODULE).v $(OTHER_SOURCES) -o $(TOP_MODULE).vvp | ||
|
||
build_evaluate: | ||
$(GENERATOR_COMPILER) -o $(GENERATOR_BINARY) $(GENERATOR_SOURCE) | ||
./$(GENERATOR_BINARY) $(RESULT_FILE) | ||
$(COMPILER) $(FLAGS) ${TOP_MODULE}.v ${TOP_EVALUATE_MODULE}.v $(OTHER_SOURCES) -o $(TOP_EVALUATE_MODULE).vvp | ||
|
||
run: build | ||
$(INTERPRETER) $(TOP_MODULE).vvp | ||
|
||
run_evaluate: build_evaluate | ||
$(INTERPRETER) $(TOP_EVALUATE_MODULE).vvp $(EVALUATE_FLAGS) > $(EVALUATE_FILE) 2>&1 | ||
|
||
evaluate: run_evaluate | ||
./${GRADE_SCRIPT} $(EVALUATE_FILE) | ||
|
||
clean: | ||
rm *.vvp $(DUMP_VCD_FILE) $(EVALUATE_FILE) $(RESULT_FILE) $(GENERATOR_BINARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# FPU | ||
|
||
Implmentați modulul verilog pentru un FPU (floating point unit) cu 2 operanzi 32-bits IEEE754. | ||
|
||
Intrările sunt: | ||
- i_w_op1 - primul operand (32 de biți) | ||
- i_w_op2 - al doilea operand (32 biți) | ||
- i_w_opsel - linie de selecție a operației (3 biți) | ||
|
||
Ieșirea este: | ||
- o_w_out - rezultatul operației între cei doi operanzi (32 biți) | ||
|
||
Operațiile sunt: | ||
|
||
| Operation Code (i_w_opsel) | Operation | Result | | ||
|--------------------------|-----------------|-------| | ||
| 000 | Addition | op1 + op2 | | ||
| 001 | Subtraction | op1 - op2 | | ||
| 010 | Multiplication | op1 * op2 | | ||
| 011 | Division | op1 / op2 | | ||
| 100 | Negation | -op1 | | ||
| 101 | Absolute Value | \|op1\| | | ||
| 110 | Less than | op1 < op2 | | ||
| 111 | Equal | op1 == op2 | | ||
|
||
Standardul IEEE754 poate fi găsit la următorul [link](https://curs.upb.ro/2024/mod/resource/view.php?id=46321). | ||
|
||
Pentru a vă ajuta în rezolvare avem următoarele materiale video: | ||
- [Reprezentare IEEE754](https://ctipub-my.sharepoint.com/:v:/g/personal/stefan_dan_ciocirlan_upb_ro/EdT8OQWyXc9MvafVmUvP1_wBW3bESoQJ7kAXzvPbNLJyYg?e=rXFLan&nav=eyJwbGF5YmFja09wdGlvbnMiOnt9LCJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbE1vZGUiOiJtaXMiLCJyZWZlcnJhbFZpZXciOiJwb3N0cm9sbC1jb3B5bGluayIsInJlZmVycmFsUGxheWJhY2tTZXNzaW9uSWQiOiJlN2FhMThmZi02ZDk0LTQ5YWMtYWM0NC0yMDRmNGMyNTA4MjEifX0%3D) | ||
- [Adunare IEEE754](https://ctipub-my.sharepoint.com/:v:/g/personal/stefan_dan_ciocirlan_upb_ro/EZ1mlBsUVxRApccFv7Rj4JQBrZwYJ1JCb80YVsfhyqgWkw?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=t23cOK) | ||
- [Scădere IEEE754](https://ctipub-my.sharepoint.com/:v:/g/personal/stefan_dan_ciocirlan_upb_ro/EYp6Tk2nUONPiySrwgjl83EBahG2wOaPyreZWE2EQ3mFDw?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=lVwmop) | ||
- [Înmulțire IEEE754](https://ctipub-my.sharepoint.com/:v:/g/personal/stefan_dan_ciocirlan_upb_ro/EcWX-oXDWU5KnyecEDasxjoBHSzzf-8NvoZyCfo8Ca_9fg?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=qbElkD) | ||
- [Împărțire 1 IEEE754](https://ctipub-my.sharepoint.com/:v:/g/personal/stefan_dan_ciocirlan_upb_ro/EVWvarvhvUZAlG80QO32SaQByTHOZLsjb5z6TDz1iio1gg?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=pm3lPI) | ||
- [Împărțire 2 IEEE754](https://ctipub-my.sharepoint.com/:v:/g/personal/stefan_dan_ciocirlan_upb_ro/EaU-1JasofxGpIesR43Od7wBQI93emIt51zO4YVaFstI4Q?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=HNlxCk) | ||
- [Operații Relaționale IEEE754](https://ctipub-my.sharepoint.com/:v:/g/personal/stefan_dan_ciocirlan_upb_ro/EeCqdJoCAaxBq0f0fjSPbTMBbRsiFfuubVkHrR7qb4Aa4A?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=eXKb4E) | ||
- [Rounding IEEE754](https://youtu.be/wbxSTxhTmrs?t=529) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
`timescale 1ns / 1ps | ||
module evaluate_fpu(); | ||
//Inputs | ||
reg[31:0] l_r_op1; | ||
reg[31:0] l_r_op2; | ||
reg[2:0] l_r_sel; | ||
reg[2:0] l_r_aux_sel; | ||
|
||
//Outputs | ||
wire[31:0] l_w_out; | ||
|
||
//Expected outputs | ||
reg[31:0] l_r_out; | ||
|
||
//local variables for loop | ||
integer i, j, k; | ||
integer file_descriptor; | ||
integer scan_result; | ||
reg[127:0] input_file; | ||
|
||
//Module initialization | ||
fpu uut ( | ||
.o_w_out(l_w_out), | ||
.i_w_op1(l_r_op1), | ||
.i_w_op2(l_r_op2), | ||
.i_w_opsel(l_r_sel) | ||
); | ||
|
||
//Simulation tests | ||
initial begin | ||
|
||
//get from the command line the input file | ||
if (!$value$plusargs("INPUT_FILE=%s", input_file)) begin | ||
$display("Error: You must specify the input file"); | ||
$finish; | ||
end | ||
|
||
for (i=0; i<8; i=i+1) begin | ||
l_r_sel = i; | ||
file_descriptor = $fopen(input_file, "r"); | ||
if (file_descriptor == 0) begin | ||
$display("Error opening file"); | ||
$finish; | ||
end | ||
#5; | ||
|
||
while (!$feof(file_descriptor)) begin | ||
scan_result = $fscanf(file_descriptor, "%h ", l_r_op1); | ||
scan_result = $fscanf(file_descriptor, "%h ", l_r_op2); | ||
scan_result = $fscanf(file_descriptor, "%h ", l_r_aux_sel); | ||
scan_result = $fscanf(file_descriptor, "%h\n", l_r_out); | ||
|
||
if (l_r_aux_sel == l_r_sel) begin | ||
#5; | ||
if (l_r_out !== l_w_out) begin | ||
$display("Error: (hex_values) l_w_out = %0h correct %0h, op1 = %0h, op2 = %0h, sel = %0h", l_w_out, l_r_out, l_r_op1, l_r_op2, l_r_sel); | ||
end else begin | ||
$display("OK"); | ||
end | ||
#5; | ||
end | ||
end | ||
$fclose(file_descriptor); | ||
#5; | ||
end | ||
//finish the simulation | ||
$finish; | ||
end | ||
endmodule |
Oops, something went wrong.