-
Notifications
You must be signed in to change notification settings - Fork 33
new components: cam and replacement #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
desmonddak
wants to merge
46
commits into
intel:main
Choose a base branch
from
desmonddak:cache
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
05d77fe
new components: cam and replacement
desmonddak 41bf98e
test/memory added
desmonddak be4dfbf
smoke test for Cache working
desmonddak 11f056f
cleanup and more file moves
desmonddak b1771d7
updated code docs for cache
desmonddak fa52418
updated code docs for cache
desmonddak 26bf9e2
Cache passes a fill then read exhaustive test avoiding evictions
desmonddak 8513ff1
Cache cleanup: still need to figure out TagRF valid bit storage
desmonddak 6bf67b3
Cache cleanup -- use different interfaces for read vs write
desmonddak e6ead6f
Cache cleanup -- remove vcd generation
desmonddak ac75a69
updated replacement to be cleaner
desmonddak 22432a1
added valid-bit handling for tags
desmonddak 853afe2
forgot to remove wavedumper
desmonddak b8a10fa
working with valid bit but not yet invalidating
desmonddak 08727d2
invalidate logic in, needs tests
desmonddak ff381bd
invalidate working
desmonddak 9ef67c2
write to a hit, double-write tests
desmonddak 5f99bf4
Better SV output, cleaner ROHD
desmonddak 3389438
Cleaner ROHD, should pass CI
desmonddak 104e6aa
Update cache_test.dart
desmonddak b29d48c
better organization of cache files, cleanup of comments
desmonddak ad869e5
use flop vs Sequential and reduce loops
desmonddak 0637d7c
better naming for the ReadCache
desmonddak 0021f24
simplified rohd_hcl.dart and udpated cam to remove enable
desmonddak d8b4a45
proposed Cache interface for handling evictions
desmonddak 79b755b
Merge branch 'main' into cache
desmonddak fee2be5
prepare for invalidate output
desmonddak a3391d7
Reproduced combinational RF read issue
desmonddak aa090f2
working on cache bug fix
desmonddak 0df1d26
overlap read and write testing
desmonddak a48cc2b
Added Cache and Cam documentation
desmonddak 11c3d95
pull the vcd generation
desmonddak 85a7966
cache componentry
desmonddak f0a387b
doc update
desmonddak 2194e40
new caching components
desmonddak 98c2d10
minor fixes that blocked CI
desmonddak e9f01ba
compute cache hit without request.valid
desmonddak 8fe97c3
directory reorg for cache components
desmonddak a0694a8
updated cache components with eviction, etc
desmonddak 94c195a
add logicstructure components using new addTyped protocol
desmonddak 3aae40a
better docs for caches
desmonddak 10aeb52
new primer on creating a good module
desmonddak b0e5c84
removed unused module
desmonddak d3b507f
combinational dependency ready->valid
desmonddak 1e0a5e6
cache configuration
desmonddak 463a48d
cleanup
desmonddak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,156 @@ | ||
| # How to Build a Great Component in ROHD | ||
|
|
||
| Since ROHD is an extension of the Dart programming language, please follow all | ||
| Dart programming and documentation conventions. | ||
|
|
||
| The `Module` class is the base class used in ROHD to build components, and | ||
| calling the constructor the `Module` instantiates the component and connects it | ||
| to signals passed into the constructor. | ||
|
|
||
| ## Port Construction and Connection | ||
|
|
||
| A `Module` constructor takes `Logic` arguments and parameters to generate a | ||
| hardware component. The `Logic` arguments are actually the external signals | ||
| being connected to by the `Module`, and so internal copies must be constructed | ||
| and connected to these arguments by the constructor and only then can other | ||
| logic signals be connected to these copies. If you do not do this, a trace error | ||
| will occur, but that only happens when this module is instantiated in another -- | ||
| it will not show up while testing which just instantiates the module in a test | ||
| environment. See [Modules](https://intel.github.io/rohd-website/docs/modules/) | ||
| for more detail. | ||
|
|
||
| A key pattern used in ROHD-HCL is to have the constructor take only input | ||
| signals as arguments and generate the output signal widths based on these | ||
| signals and other parameters. | ||
|
|
||
| ## Port Types | ||
|
|
||
| Signals can take various forms in ROHD and it is important to consider what form | ||
| you want for the API of the `Module` you are building. ROHD supports the basic | ||
| `Logic` signal which has its width encode (therefore you should not be using | ||
| width as a parameter to a `Module`). ROHD provides basic cloning and accessor | ||
| helper functions like `addInput` and `input`. | ||
|
|
||
| `LogicArray` is a uniform multi-dimensional array of leaf `Logic` signals. Using | ||
| this for input/output will require special routines like `addInputArray` to | ||
| connect external and internal signals. Examples of using `LogicArray` are in the | ||
| `Serializer` and `Deserializer` components. | ||
|
|
||
| `LogicStructure` is a hierarchical concatenation of named `Logic` fields, where | ||
| the `FloatingPoint` arithmetic type is an example used in the | ||
| `FloatingPointMultiplierSimple` module. We can also pass in `LogicStructure` as | ||
| a type for certain components so that the field structure is not lost on input | ||
| and output. A good example of this is `Fifo`, which is templatized on | ||
| `LogicType` to allow for us to generate a `Fifo` for a particular | ||
| `LogicStructure` to use when pushing and popping the data in and out. Here, | ||
| `addTypedInput` is a method used to help with creating the internal signals. | ||
|
|
||
| `Interface` is similar to `LogicStructure` yet it provides an ability to define | ||
| directionality to the internal fields, useful in connecting modules that share a | ||
| common protocol such as the `ApbInterface`. See | ||
| [Interfaces](https://intel.github.io/rohd-website/docs/interfaces). A few | ||
| examples of key general interface types that you can inherit from are the | ||
| `PairInterface` and the `DataPortInterface`. the `Memory` module has a good | ||
| example of how `DataPortInterface`s are cloned internally using its `connectIO` | ||
| method. | ||
| The `Fifo` has a good example of using an `Interface` to wrap a `LogicStructure`. | ||
|
|
||
| When wrapping `LogicStructure` with `Interface`, don't name the `LogicStructure` | ||
| as `Interface` will need to uniquify (a known bug in `Interface`). | ||
|
|
||
| An important kind of `Interface` is the `PairInterface` which is designed for | ||
| bidirectional communication and provides a `pairConnectIO` method for connecting | ||
| external and internal ports based on producer/consumer filtering. | ||
|
|
||
| ## Logic Internals | ||
|
|
||
| Signal logic is constructed in a ROHD component by assignment and simple logic | ||
| operations like and (`&`) and or (`|`) as well as multiplexing (`mux`) and | ||
| flopping (`flop`). See | ||
| [operations](https://intel.github.io/rohd-website/docs/logic-math-compare/) for | ||
| more detail. | ||
|
|
||
| More complex logic can be constructed using | ||
| [`Sequental`](https://intel.github.io/rohd-website/docs/sequentials/) and | ||
| [`Combinational`](https://intel.github.io/rohd-website/docs/conditionals/) | ||
| blocks similar to SystemVerilog `always` blocks. There is also a | ||
| [`FiniteStateMachine`](https://intel.github.io/rohd-website/docs/fsm/) | ||
| construct for state machines and a | ||
| [`Pipeline`](https://intel.github.io/rohd-website/docs/pipelines/) construct | ||
| for assisting with pipelined logic. | ||
|
|
||
| Try to minimize the addition of new internal signals, by just reusing the | ||
| signals created by the ports or by subcomponents. Use `.named` to create clean | ||
| SystemVerilog names. | ||
|
|
||
| ### Debug | ||
|
|
||
| If you want to expose internal signals onto the interface of a `Module` for debug, a simple method is to declare them as a field in the class (Use @protected in case this is exposed so it doesn't become part of the API). This signal will be available in tests as module.field. | ||
|
|
||
| ## Unit Testing | ||
|
|
||
| A good component has unit tests to validate the component and provide examples | ||
| of use. We use the Dart testing framework which requires that tests are stored | ||
| in the `test/` directory and are named ending in `_test.dart`. An example of | ||
| unit tests for a component is shown below. Note that grouping of tests can | ||
| reuse a common component built for multiple tests. Also note that each test | ||
| with sequential logic will need a `SimpleClockGenerator`, a `Simulator.run()` | ||
| and an `endSimulation`. Some helper methods (like `.waitCycles`) are available | ||
| in the rohd-fv package. | ||
|
|
||
| ```dart | ||
| void main() { | ||
| tearDown(() async { | ||
| await Simulator.reset(); | ||
| }); | ||
|
|
||
| group('test narrow component', () { | ||
| final input = Logic(width: 5); | ||
| final component = MyComponent(input); | ||
| final output = component.out; | ||
|
|
||
| test('MyComponent smoke test', () async { | ||
| final clk = SimpleClockGenerator(10).clk; | ||
|
|
||
| unawaited(Simulator.run()); | ||
| reset.inject(1); | ||
| await clk.waitCycles(3); | ||
| reset.inject(0); | ||
| await clk.waitCycles(1); | ||
| input.inject(1); | ||
| await clk.waitCycles(3); | ||
| expect(output.value, equals(Const(1, width: output.width))); | ||
|
|
||
| await Simulator.endSimulation(); | ||
| }); | ||
|
|
||
| test('MyComponent second test', () async { | ||
| final clk = SimpleClockGenerator(10).clk; | ||
|
|
||
| unawaited(Simulator.run()); | ||
| reset.inject(1); | ||
| await clk.waitCycles(3); | ||
| reset.inject(0); | ||
| await clk.waitCycles(1); | ||
| input.inject(6); | ||
| await clk.waitCycles(3); | ||
| expect(output.value, equals(Const(6, width: output.width))); | ||
|
|
||
| await Simulator.endSimulation(); | ||
| }); | ||
| }); | ||
| } | ||
| ``` | ||
|
|
||
| Prefer using `waitCycles` instead of `nextPosEdge` and use `inject` instead of | ||
| `put` when working with sequential tests. | ||
|
|
||
| When testing a combinational path, and you `inject` inputs after a positive | ||
| clock edge, use `nextNegEdge` to look at the value mid-way through the clock | ||
desmonddak marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cycle, because if you wait for the next positive edge, then you will miss this | ||
| output as it will be whatever is triggered by the next clk edge. | ||
|
|
||
| While creating unit tests, you can just run the tests for your component instead | ||
| of running the entire suite of ROHD-HCL tests. The entire regression suite | ||
| takes quite a long time and is only necessary if you make changes to some core | ||
| functionality. | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.