You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/design_notebooks/2025fall/lz3007.md
+41-21Lines changed: 41 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ We read the documentations on the [instruction set](https://user.eng.umd.edu/~bl
21
21
1. One idea was that the 16-bit instruction set in machine code is passed into the module, but that idea was discarded because there was no way of obtaining the addresses of the registers and immediate value through the machine code.
22
22
2. Another idea was that the opcode, registers, and immediate values are passed into the module as inputs and we would use the opcode to decide on what the output address would be. But, we were unsure on how the incrementation of the PC would work and how the address would be chosen, given two 3-bit registers (A and B).
23
23
24
-
We consulted Noah about the inputs and outputs of the PC. From my interpretation, he explained that there are 3 possible jumps for the output address: incrementing of 1, jumping to register B (JALR instruction), and jumping to the immediate value (BEQ instruction). For all 3 possible jumps, there should be an input with the 16-bit address. A multiplexer, given an input from another module, is used to choose which address would be the one the PC would actually point to.
24
+
We consulted Noah about the inputs and outputs of the PC. From my interpretation, he explained that there are 3 possible jumps for the output address: incrementing of 1, jumping to register B (```JALR``` instruction), and jumping to the immediate value (```BEQ``` instruction). For all 3 possible jumps, there should be an input with the 16-bit address. A multiplexer, given an input from another module, is used to choose which address would be the one the PC would actually point to.
25
25
26
26
My partner and I had some differences in our interpretations, so we decided to write our code in separate files and push both versions to the repository ([My PC](https://github.com/Ghqlq/Processor-Design-Projects/blob/main/pc2.v) and [My Partner's PC](https://github.com/Ghqlq/Processor-Design-Projects/blob/main/program_counter.v)).
27
27
@@ -32,18 +32,18 @@ My partner and I had some differences in our interpretations, so we decided to w
32
32
* Fixed PC to pass all testbench tests
33
33
* Completed ALU and passed the testbench tests
34
34
35
-
The [sequential implementation document](https://user.eng.umd.edu/~blj/risc/RiSC-seq.pdf) was reviewed to understand how the inputs (given in the slides) were manipulated to be passed into the multiplexers. Since there are four possible operations to choose from—add, bitwise nand, passing src1, and setting EQ if equal—the input FUNC_alu is 2-bits.
35
+
The [sequential implementation document](https://user.eng.umd.edu/~blj/risc/RiSC-seq.pdf) was reviewed to understand how the inputs (given in the slides) were manipulated to be passed into the multiplexers. Since there are four possible operations to choose from—```add```, bitwise ```nand```, passing ```src1```, and setting ```EQ``` if equal—the input ```FUNC_alu``` is 2-bits.
36
36
37
-
The multiplexers inputs are 1-bit signals that choose whether the left-shifted immediate value or the source1 input [MUX_alu1] and the whether the sign-extended immediate value or the source2 input [MUX_alu2] are used as the source inputs for the internal multiplexer of the ALU that operates on the two inputs.
37
+
The multiplexers inputs are 1-bit signals that choose whether the left-shifted immediate value or the source1 input ```MUX_alu1``` and the whether the sign-extended immediate value or the source2 input ```MUX_alu2``` are used as the source inputs for the internal multiplexer of the ALU that operates on the two inputs.
38
38
39
39
The outputs, EQ (1-bit) and alu_out (16-bit), are selected based on the following operations:
EQ is always being set to (src1 == src2) for every operation.
46
+
```EQ``` is always being set to ```src1 == src2``` for every operation.
47
47
48
48
For this week's project, my partner and I worked separately, meeting once to check each other's progress. Therefore, we worked on separate alu files: [My ALU](https://github.com/Ghqlq/Processor-Design-Projects/blob/main/alu2.v) and [My Partner's ALU](https://github.com/Ghqlq/Processor-Design-Projects/blob/main/alu.v).
49
49
@@ -55,32 +55,32 @@ When working on the ALU, I had the following questions: When do you decide to ma
55
55
* Completed the Register File
56
56
* Fixed Register File to pass all test cases in the testbench
57
57
58
-
The [Instruction Set Architecture](https://user.eng.umd.edu/~blj/risc/RiSC-isa.pdf) was reviewed. The 16-bit instruction input was separated into different variables: opCode, rA, rB, rC, signed_imm, and imm. An array of eight 16-bit registers was created.
58
+
The [Instruction Set Architecture](https://user.eng.umd.edu/~blj/risc/RiSC-isa.pdf) was reviewed. The 16-bit instruction input was separated into different variables: ```opCode```, ```rA```, ```rB```, ```rC```, ```signed_imm```, and ```imm```. An array of eight 16-bit registers was created.
59
59
60
-
At first, I thought the opcode would be used to assign the results (rB + rC, rB nand rC, etc) to rA. But, I realized that the calculations are done in the ALU, so the register value should be updated with the values inputted to the register file (alu_out, mem_out, pc).
60
+
At first, I thought the opcode would be used to assign the results (```rB + rC```, ```rB nand rC```, etc) to ```rA```. But, I realized that the calculations are done in the ALU, so the register value should be updated with the values inputted to the register file (```alu_out```, ```mem_out```, ```pc```).
61
61
62
-
Looking at the diagram in the Instruction Set Architecture, I think the MUX_tgt is used to determine what value the destination register is updated with, if the WE bit is turned on. The outputs for the register file are determined on the opcode of the inputted instruction.
62
+
Looking at the diagram in the Instruction Set Architecture, I think the ```MUX_tgt``` is used to determine what value the destination register is updated with, if the ```WE``` bit is turned on. The outputs for the register file are determined on the opcode of the inputted instruction.
63
63
64
64
### Testing code with Testbench
65
65
There were many syntax and logic errors while testing my code with the testbench. Below are the things I realized and fixed.
66
-
* MUX_rf: used to determine if reg_out2 is rA or rC
66
+
* MUX_rf: used to determine if ```reg_out2``` is ```rA``` or ```rC```
67
67
* The default case is to output 16'b0 for both outputs
68
-
* Need to extend the signed_imm and the 10-bit imm for reg_out2
68
+
* Need to extend the signed_imm and the 10-bit imm for ```reg_out2```
**Notes:** As I am writing this week's design notebook, I realize that it doesn't make sense to update the register using the value of the current instruction's rA. So, I am unsure as to why my current code (which does the above) passes all the test cases.
75
+
**Notes:** As I am writing this week's design notebook, I realize that it doesn't make sense to update the register using the value of the current instruction's ```rA```. So, I am unsure as to why my current code (which does the above) passes all the test cases.
76
76
77
77
## Week 5: 10/06/2025 - 10/12/2025
78
78
79
79
* Fixed register file using the updated testbench, passed all tests
80
80
81
81
#### There was no new assignment for this week.
82
82
83
-
The previous testbench was incorrect because the Register File should not take the instruction, only the registers (rA, rB, rC). While fixing my Register File code using the fixed testbench, I realized the following about my code:
83
+
The previous testbench was incorrect because the Register File should not take the instruction, only the registers (```rA```, ```rB```, ```rC```). While fixing my Register File code using the fixed testbench, I realized the following about my code:
84
84
1. The Register File should NOT sign-extend or left shift the immediate value; in fact, the register does not take the immediate value as an input at all.
85
85
2. The opcode should not be an input for any of the modules, only the signals from the Control Unit and the outputs from other modules are inputs.
86
86
@@ -90,7 +90,7 @@ The previous testbench was incorrect because the Register File should not take t
90
90
91
91
* Completed testbench for the Data Memory module
92
92
93
-
At the start, I created different test cases, like the verfication of the initial values in the memory, testing if the reg_out value was written to the address (alu_out) if WE_dmem = 0 (should not write), and overwriting previously modified memory data. One problem I had was that I was checking all 65536 memory locations, which is very inefficient. So, I changed the tests cases to only check the few memory addresses that were being tested.
93
+
At the start, I created different test cases, like the verfication of the initial values in the memory, testing if the ```reg_out``` value was written to the address ```alu_out``` if ```WE_dmem = 0``` (should not write), and overwriting previously modified memory data. One problem I had was that I was checking all 65536 memory locations, which is very inefficient. So, I changed the tests cases to only check the few memory addresses that were being tested.
94
94
95
95
The biggest problem that I encountered while writing the testbench was the verilog syntax and logic. Within an initial block, declaring an integer after an executable statements would cause errors and displaying text right after one another would also cause errors. However, all these errors would point to the $finish line at the very end of the code, so it was difficult to know which lines were actually causing errors.
96
96
@@ -103,7 +103,7 @@ The biggest problem that I encountered while writing the testbench was the veril
103
103
* Completed Control and Data Memory modules
104
104
* Passed all testcases for the Control module, using the provided testbench
105
105
106
-
The Control module selects the value of the output signals: WErf, WEdmem, MUXalu1, MUXalu2, MUXrf, MUXtgt, FUNCalu, and MUXpc, based on the opcode input and the EQ signal (only for MUXpc). The first step was to find the corrosponding opcodes to the instructions using the [instruction set](https://user.eng.umd.edu/~blj/risc/RiSC-isa.pdf). The output signals were found by looking at the "Instruction Dataflow" diagrams for each instruction found in the [sequential implementation document](https://user.eng.umd.edu/~blj/risc/RiSC-seq.pdf). Another useful part of the document was the "Putting it all together" section that shows which modules the signals are sent to and describes what the signals are used for in the modules.
106
+
The Control module selects the value of the output signals: ```WErf```, ```WEdmem```, ```MUXalu1```, ```MUXalu2```, ```MUXrf```, ```MUXtgt```, ```FUNCalu```, and ```MUXpc```, based on the opcode input and the ```EQ``` signal (only for ```MUXpc```). The first step was to find the corrosponding opcodes to the instructions using the [instruction set](https://user.eng.umd.edu/~blj/risc/RiSC-isa.pdf). The output signals were found by looking at the "Instruction Dataflow" diagrams for each instruction found in the [sequential implementation document](https://user.eng.umd.edu/~blj/risc/RiSC-seq.pdf). Another useful part of the document was the "Putting it all together" section that shows which modules the signals are sent to and describes what the signals are used for in the modules.
107
107
108
108
[GitHub: Control Module Code](https://github.com/Ghqlq/Processor-Design-Projects/blob/main/control2.v)
109
109
@@ -116,6 +116,26 @@ The Control module selects the value of the output signals: WErf, WEdmem, MUXalu
The coding was not a problem, but the commands and all the generated files were confusing. Running ```cmake``` generates a lot files that were unfamiliar.
130
+
131
+
**Remaining Questions/Notes**
132
+
* I am still confused when to use ```ninja``` or ```cmake```. What is the difference with how you use them?
133
+
* What does the ```make hello.o``` and ```make hello.i``` do? What are those build files used for?
I was a little confused with where to write my code and what files I should be looking at for the exercises. The coding was not very difficult.
140
+
141
+
Another issue I had trouble with was pushing the forked repo's work to the repo that I share with my groupmate. When I pushed the folder for the first time, the folder was pushed as a Git submodule(?). I had to delete the Git metadata to push the folder normally ```rm onboarding-lab-2/.git```.
0 commit comments