Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
makropga
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Compu
makropga
Commits
e5333578
Commit
e5333578
authored
6 months ago
by
Leo
Browse files
Options
Downloads
Patches
Plain Diff
add alu
parent
46049d8e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+4
-0
4 additions, 0 deletions
.gitignore
alu.v
+47
-0
47 additions, 0 deletions
alu.v
top.json
+558
-156
558 additions, 156 deletions
top.json
top.v
+33
-4
33 additions, 4 deletions
top.v
with
642 additions
and
160 deletions
.gitignore
0 → 100644
+
4
−
0
View file @
e5333578
icarusTest
top.asc
top.bin
wave.vcd
This diff is collapsed.
Click to expand it.
alu.v
0 → 100644
+
47
−
0
View file @
e5333578
module
alu
(
input
clk
,
input
wrA
,
input
wrB
,
input
enAdd
,
input
enSub
,
input
clr
,
input
[
15
:
0
]
busIn
,
output
[
15
:
0
]
busOut
);
wire
[
15
:
0
]
aVal
;
wire
[
7
:
0
]
aValLo
;
wire
[
7
:
0
]
aValHi
;
assign
aVal
=
{
aValHi
,
aValLo
}
;
register
aReg
(
.
clk
(
clk
),
.
clr
(
clr
),
.
in
(
busIn
),
.
wrHi
(
wrA
),
.
wrLo
(
wrA
),
.
enHi
(
1'b0
),
.
enLo
(
1'b0
),
.
currentHi
(
aValHi
),
.
currentLo
(
aValLo
)
);
wire
[
15
:
0
]
bVal
;
wire
[
7
:
0
]
bValLo
;
wire
[
7
:
0
]
bValHi
;
assign
bVal
=
{
bValHi
,
bValLo
}
;
register
bReg
(
.
clk
(
clk
),
.
clr
(
clr
),
.
in
(
busIn
),
.
wrHi
(
wrB
),
.
wrLo
(
wrB
),
.
enHi
(
1'b0
),
.
enLo
(
1'b0
),
.
currentHi
(
bValHi
),
.
currentLo
(
bValLo
)
);
assign
busOut
=
enAdd
?
aVal
+
bVal
:
(
enSub
?
aVal
-
bVal
:
15'b0
);
endmodule
\ No newline at end of file
This diff is collapsed.
Click to expand it.
top.json
+
558
−
156
View file @
e5333578
This diff is collapsed.
Click to expand it.
top.v
+
33
−
4
View file @
e5333578
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
`include
"register.v"
`include
"register.v"
`include
"ram.v"
`include
"ram.v"
`include
"pc.v"
`include
"pc.v"
`include
"alu.v"
module
top
(
input
[
3
:
0
]
SW
,
output
LED_R
,
output
LED_G
,
output
LED_B
,
output
TX
,
input
P3_10
);
module
top
(
input
[
3
:
0
]
SW
,
output
LED_R
,
output
LED_G
,
output
LED_B
,
output
TX
,
input
P3_10
);
...
@@ -12,10 +13,11 @@ module top(input [3:0] SW, output LED_R, output LED_G, output LED_B, output TX,
...
@@ -12,10 +13,11 @@ module top(input [3:0] SW, output LED_R, output LED_G, output LED_B, output TX,
wire
[
15
:
0
]
bus_in_3
;
wire
[
15
:
0
]
bus_in_3
;
wire
[
15
:
0
]
bus_in_4
;
wire
[
15
:
0
]
bus_in_4
;
wire
[
15
:
0
]
bus_in_5
;
wire
[
15
:
0
]
bus_in_5
;
wire
[
15
:
0
]
bus_in_6
;
reg
[
15
:
0
]
bus_in_2
=
0
;
reg
[
15
:
0
]
bus_in_2
=
0
;
wire
[
15
:
0
]
bus_out
;
wire
[
15
:
0
]
bus_out
;
assign
bus_out
=
bus_in_1
|
bus_in_2
|
bus_in_3
|
bus_in_4
|
bus_in_5
;
assign
bus_out
=
bus_in_1
|
bus_in_2
|
bus_in_3
|
bus_in_4
|
bus_in_5
|
bus_in_6
;
reg
[
22
:
0
]
clock_div
;
reg
[
22
:
0
]
clock_div
;
reg
sClk
;
reg
sClk
;
...
@@ -92,6 +94,22 @@ module top(input [3:0] SW, output LED_R, output LED_G, output LED_B, output TX,
...
@@ -92,6 +94,22 @@ module top(input [3:0] SW, output LED_R, output LED_G, output LED_B, output TX,
);
);
reg
wrA
=
0
;
reg
wrB
=
0
;
reg
enSub
=
0
;
reg
enAdd
=
0
;
alu
alu
(
.
clk
(
clk
),
.
wrA
(
wrA
),
.
wrB
(
wrB
),
.
enAdd
(
enAdd
),
.
enSub
(
enSub
),
.
clr
(
clr
),
.
busIn
(
bus_out
),
.
busOut
(
bus_in_6
)
);
initial
begin
initial
begin
$
readmemh
(
"control.mem"
,
controlMemory
);
$
readmemh
(
"control.mem"
,
controlMemory
);
$
dumpfile
(
"wave.vcd"
);
$
dumpfile
(
"wave.vcd"
);
...
@@ -140,15 +158,26 @@ module top(input [3:0] SW, output LED_R, output LED_G, output LED_B, output TX,
...
@@ -140,15 +158,26 @@ module top(input [3:0] SW, output LED_R, output LED_G, output LED_B, output TX,
// #2 enRam = 1;
// #2 enRam = 1;
// #2 enRam = 0;
// #2 enRam = 0;
#
2
incPc
=
1
;
#
2
enPc
=
1
;
// #2 wrInst=1;
// #2 wrInst=1;
#
2
bus_in_2
=
5
;
#
2
wrA
=
1
;
#
2
wrA
=
0
;
#
2
bus_in_2
=
2
;
#
2
wrB
=
1
;
#
2
wrB
=
0
;
#
2
bus_in_2
=
0
;
#
2
enAdd
=
1
;
#
2
enAdd
=
0
;
#
2
enSub
=
1
;
#
20
$
finish
;
//
#20 $finish;
end
end
// reg [7:0] comp1;
// reg [7:0] comp1;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment