Skip to content

Commit c645ecf

Browse files
Flattening cobalt
1 parent 6d42056 commit c645ecf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+932
-258
lines changed

.gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "prelude"]
22
path = prelude
33
url = https://github.com/facebook/buck2-prelude.git
4-
[submodule "vnd/cobalt/vnd/cobble"]
5-
path = vnd/cobalt/vnd/cobble
4+
[submodule "vnd/cobble"]
5+
path = vnd/cobble
66
url = git@github.com:oxidecomputer/cobble-build.git

BUCK

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
load(":rdl.bzl", "rdl_file", "rdl_gen")
2+
3+
rdl_file(
4+
name = "gimlet_seq_fpga_regs",
5+
src = "gimlet_seq_fpga_regs.rdl",
6+
deps = [],
7+
)
8+
9+
rdl_gen(
10+
name = "gimlet_regs",
11+
srcs = [":gimlet_seq_fpga_regs"],
12+
outputs = ["gimlet.vhd", "gimlet.html", "gimlet.json", "gimlet.bsv"]
13+
)
14+
215
rdl_file(
316
name = "demo_rdl",
417
src = "demo.rdl",
@@ -13,5 +26,5 @@ rdl_file(
1326
rdl_gen(
1427
name = "demo_test",
1528
srcs = [":demo_top"],
16-
outputs = ["demo_test_pkg.vhd", "demp_test.html"]
29+
outputs = ["demo.vhd", "demo.bsv", "demo.json", "demp_test.html"]
1730
)

BUILD.conf

+129-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,123 @@
11
# -*- python -*- vim:syntax=python:
22

3-
plugin_path('tools/site_cobble')
4-
subproject('cobalt', 'vnd/cobalt')
3+
plugin_path('tools/site_cobble', 'vnd/cobble/src/cobble/target')
4+
install('bluespec')
5+
install('bsv_fpga_version')
6+
install('rdl')
7+
install('c')
8+
install('nextpnr')
9+
install('shell')
10+
install('yosys')
511

6-
environment('ignition_target', base = 'cobalt//ice40', contents = {
12+
environment('default', contents = {
13+
'bsc': VARS.get('bluespec', 'bin', default='bsc'),
14+
'bsc_flags': [
15+
'-q',
16+
'-show-range-conflict',
17+
],
18+
'bluescan': ROOT + '/tools/site_cobble/bluescan.py',
19+
'bluescan_flags': [
20+
'--bs-prefix ' + VARS.get('bluespec', 'prefix', default='/usr/local/bluespec')
21+
],
22+
'yosys': VARS.get('yosys', 'bin', default='yosys'),
23+
# Suppress warnings about translate_off and parallel_case since these
24+
# are regularly found in BSC generated code. Additionally, suppress warning
25+
# about limited tri-state support as it is supported for our devices.
26+
'yosys_flags': [
27+
'-w', 'translate_off',
28+
'-w', 'parallel_case',
29+
'-w', '"Yosys has only limited support for tri-state logic at the moment."',
30+
],
31+
32+
'cxx': VARS.get('c', 'cxx', default='c++'),
33+
'cxx_flags': [
34+
'-std=c++17',
35+
'-Wall',
36+
'-Wextra',
37+
'-Werror',
38+
'-I' + ROOT,
39+
],
40+
'c_link_flags': [
41+
],
42+
'ar': VARS.get('c', 'ar', default='ar'),
43+
'gen_git_version_bsv': ROOT + '/tools/site_cobble/gen_git_version_bsv.py',
44+
'rdl_script': ROOT + '/tools/site_cobble/rdl_pkg/rdl_cli.py',
45+
})
46+
47+
environment('bluesim_default', base = 'default', contents = {
48+
'bsc_flags': [
49+
'-check-assert',
50+
# Suppress C++ compiler warnings in Bluesim generated code.
51+
'-Xc++', '-Wno-dangling-else',
52+
'-Xc++', '-Wno-bool-operation',
53+
],
54+
})
55+
56+
environment('bluesim_debug', base = 'bluesim_default', contents = {
57+
'bsc_flags': [
58+
'-keep-fires',
59+
],
60+
})
61+
62+
environment('cxxrtl_default', base = 'default', contents = {
63+
'yosys_cmds': [
64+
'hierarchy -top $$top_module',
65+
],
66+
'yosys_backend': 'cxxrtl -header',
67+
'cxx_flags': [
68+
'-Wno-array-bounds',
69+
'-Wno-shift-count-overflow',
70+
],
71+
})
72+
73+
# FPGA Family environments.
74+
environment('ecp5', base = 'default', contents = {
75+
# Default synthesis commands for ECP5.
76+
'yosys_cmds': [
77+
'synth_ecp5 -top $$top_module',
78+
],
79+
'yosys_backend': 'json', # nextpnr assumes JSON input.
80+
'nextpnr_ecp5': VARS.get('nextpnr', 'ecp5', default='nextpnr-ecp5'),
81+
'nextpnr_ecp5_flags': [
82+
'-q',
83+
],
84+
'nextpnr_ecp5_pack': VARS.get('nextpnr', 'ecp5_pack', default='ecppack'),
85+
})
86+
environment('ice40', base = 'default', contents = {
87+
'yosys_cmds': [
88+
'synth_ice40 -top $$top_module',
89+
],
90+
'yosys_backend': 'json', # nextpnr assumes JSON input.
91+
'nextpnr_ice40': VARS.get('nextpnr', 'ice40', default='nextpnr-ice40'),
92+
'nextpnr_ice40_flags': [
93+
'-q',
94+
],
95+
'nextpnr_ice40_pack': VARS.get('nextpnr', 'ice40_pack', default='icepack'),
96+
})
97+
98+
# Board environments/variants.
99+
environment('ecp5_evn', base = 'ecp5', contents = {
100+
'nextpnr_ecp5_flags': [
101+
'--um5g-85k',
102+
'--package CABGA381',
103+
],
104+
'nextpnr_constraints': ROOT + '/hdl/projects/ecp5_evn/ecp5_evn_basic.lpf',
105+
})
106+
environment('ulx3s', base = 'ecp5', contents = {
107+
'nextpnr_ecp5_flags': [
108+
'--85k',
109+
'--package CABGA381',
110+
],
111+
'nextpnr_constraints': ROOT + '/hdl/projects/ulx3s/ulx3s_v20.lpf',
112+
})
113+
environment('icestick', base = 'ice40', contents = {
114+
'nextpnr_ice40_flags': [
115+
'--hx1k',
116+
'--package tq144',
117+
],
118+
'nextpnr_constraints': ROOT + '/hdl/projects/icestick/icestick.pcf',
119+
})
120+
environment('ignition_target', base = 'ice40', contents = {
7121
'bsc_flags': [
8122
'-opt-undetermined-vals',
9123
'-unspecified-to', 'X',
@@ -15,14 +129,14 @@ environment('ignition_target', base = 'cobalt//ice40', contents = {
15129
],
16130
'nextpnr_constraints': ROOT + '/hdl/ip/bsv/ignition/ignition_target.pcf',
17131
})
18-
environment('gimlet', base = 'cobalt//ice40', contents = {
132+
environment('gimlet', base = 'ice40', contents = {
19133
'nextpnr_ice40_flags': [
20134
'--hx8k',
21135
'--package ct256',
22136
'--freq 50',
23137
],
24138
})
25-
environment('sidecar_mainboard_controller', base = 'cobalt//ecp5', contents = {
139+
environment('sidecar_mainboard_controller', base = 'ecp5', contents = {
26140
'nextpnr_ecp5_flags': [
27141
'--45k',
28142
'--package CABGA554',
@@ -34,7 +148,7 @@ environment('sidecar_mainboard_controller', base = 'cobalt//ecp5', contents = {
34148
],
35149
'nextpnr_constraints': ROOT + '/hdl/projects/sidecar/mainboard/sidecar_mainboard_controller.lpf',
36150
})
37-
environment('sidecar_qsfp', base = 'cobalt//ecp5', contents = {
151+
environment('sidecar_qsfp', base = 'ecp5', contents = {
38152
'nextpnr_ecp5_flags': [
39153
'--45k',
40154
'--package CABGA554',
@@ -50,7 +164,7 @@ environment('ignitionlet_spi', base = 'ignition_target', contents = {
50164
environment('gimlet_sequencer', base = 'gimlet', contents = {
51165
'nextpnr_constraints': ROOT + '/hdl/projects/gimlet/sequencer/gimlet_sequencer.pcf',
52166
})
53-
environment('sidecar_mainboard_emulator_ecp5_evn', base='cobalt//ecp5_evn', contents = {
167+
environment('sidecar_mainboard_emulator_ecp5_evn', base='ecp5_evn', contents = {
54168
'nextpnr_constraints':
55169
ROOT + '/hdl/projects/sidecar/mainboard/emulator/sidecar_mainboard_emulator_ecp5_evn.lpf',
56170
'nextpnr_ecp5_pack_flags': [
@@ -73,3 +187,11 @@ seed('//hdl/projects/sidecar/mainboard/test')
73187
seed('//hdl/projects/sidecar/qsfp_x32')
74188
seed('//hdl/ip/bsv/ignition/test')
75189
seed('//hdl/ip/bsv/MDIO')
190+
seed('//hdl/projects/ecp5_evn')
191+
seed('//hdl/projects/ulx3s')
192+
seed('//hdl/projects/icestick')
193+
seed('//hdl/ip/bsv/examples')
194+
seed('//hdl/ip/bsv/interfaces')
195+
seed('//hdl/ip/bsv/interfaces/video')
196+
seed('//hdl/ip/bsv/test')
197+
seed('//vnd/bluespec')

hdl/ip/bsv/BUILD

+172-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,181 @@ bluespec_library('PowerRail',
1515
'power_rail/PowerRail.bsv',
1616
],
1717
deps = [
18-
'cobalt//hdl:Countdown',
19-
'cobalt//hdl:Strobe',
18+
'//hdl/ip/bsv:Countdown',
19+
'//hdl/ip/bsv:Strobe',
2020
])
2121

2222
bluespec_library('SettableCRC',
2323
sources = [
2424
'SettableCRC.bsv',
2525
])
26+
27+
bsv_fpga_version('git_version',
28+
)
29+
30+
bluespec_library('GitVersion',
31+
sources = [
32+
':git_version#git_version.bsv',
33+
],
34+
deps = [
35+
':git_version'
36+
]
37+
)
38+
39+
# Common support scaffolding
40+
bluespec_library('RegCommon',
41+
sources = [
42+
'RegCommon.bsv',
43+
],
44+
)
45+
46+
# Cobalt modules
47+
bluespec_library('Bidirection',
48+
sources = [
49+
'Bidirection.bsv',
50+
])
51+
52+
bluespec_library('BitSampling',
53+
sources = [
54+
'BitSampling.bsv',
55+
],
56+
deps = [
57+
':Strobe',
58+
])
59+
60+
bluespec_library('Countdown',
61+
sources = [
62+
'Countdown.bsv',
63+
])
64+
65+
bluespec_library('Debouncer',
66+
sources = [
67+
'Debouncer.bsv',
68+
],
69+
deps = [
70+
':TestUtils',
71+
])
72+
73+
bluespec_library('Encoding8b10b',
74+
sources = [
75+
'Deserializer8b10b.bsv',
76+
'Encoding8b10b.bsv',
77+
'Serializer8b10b.bsv',
78+
])
79+
80+
bluespec_library('InitialReset',
81+
sources = [
82+
'InitialReset.bsv',
83+
],
84+
deps = [
85+
':TestUtils',
86+
])
87+
88+
bluespec_library('IOSync',
89+
sources = [
90+
'IOSync.bsv',
91+
],
92+
deps = [
93+
':Bidirection',
94+
':WriteOnlyTriState',
95+
])
96+
97+
bluespec_library('PLL',
98+
sources = [
99+
'PLL.bsv'
100+
])
101+
102+
bluespec_library('SchmittReg',
103+
sources = [
104+
'SchmittReg.bsv'
105+
])
106+
107+
bluespec_library('SerialIO',
108+
sources = [
109+
'SerialIO.bsv'
110+
],
111+
deps = [
112+
':BitSampling',
113+
':IOSync',
114+
':Strobe',
115+
':WriteOnlyTriState',
116+
])
117+
118+
bluespec_library('Strobe',
119+
sources = [
120+
'Strobe.bsv'
121+
])
122+
123+
bluespec_library('SyncBits',
124+
sources = [
125+
'SyncBits.bsv',
126+
])
127+
128+
bluespec_library('TestUtils',
129+
sources = [
130+
'TestUtils.bsv',
131+
])
132+
133+
bluespec_library('WriteOnceReg',
134+
sources = [
135+
'WriteOnceReg.bsv',
136+
])
137+
138+
bluespec_library('WriteOnlyTriState',
139+
sources = [
140+
'WriteOnlyTriState.bsv',
141+
])
142+
143+
# Tests
144+
145+
bluesim_tests('CountdownTest',
146+
env = 'bluesim_default',
147+
suite = 'Countdown.bsv',
148+
modules = [
149+
'mkCountdownTest',
150+
],
151+
deps = [
152+
':Countdown',
153+
])
154+
155+
bluesim_tests('DebouncerTest',
156+
env = 'bluesim_default',
157+
suite = 'Debouncer.bsv',
158+
modules = [
159+
'mkDebouncerTest',
160+
'mkDebounceFastAssertTest',
161+
'mkDebounceFastDeassertTest',
162+
],
163+
deps = [
164+
':Debouncer',
165+
':TestUtils',
166+
])
167+
168+
bluesim_tests('InitialResetTests',
169+
env = 'bluesim_default',
170+
suite = 'InitialReset.bsv',
171+
modules = [
172+
'mkInitialResetTest',
173+
],
174+
deps = [
175+
':InitialReset',
176+
])
177+
178+
bluesim_tests('SchmittRegTests',
179+
env = 'bluesim_default',
180+
suite = 'SchmittReg.bsv',
181+
modules = [
182+
'mkSlowEdgeSchmittRegTest',
183+
'mkFastPositiveEdgeSchmittRegTest',
184+
'mkLongBounceSchmittRegTest',
185+
])
186+
187+
bluesim_tests('StrobeTests',
188+
env = 'bluesim_default',
189+
suite = 'Strobe.bsv',
190+
modules = [
191+
'mkPowerTwoStrobeTest',
192+
'mkPowerTwoStrobeAsCountDownTest',
193+
'mkFractionalStrobeTest',
194+
'mkLimitStrobeStrobeTest',
195+
])
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)