-
Notifications
You must be signed in to change notification settings - Fork 5
Top-level UART redux #47
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9aa4aa1
[sw] Inline `irq_global_ctrl()`
elliotb-lowrisc 486c1ef
[sw] Correct UART1 base addr & disable wrong addrs
elliotb-lowrisc 9f47567
[sw] Implement PLIC IRQ ID to peripheral mapping
elliotb-lowrisc f42a1da
[sw] Update ported `uart_tx_rx_test` program
elliotb-lowrisc c9fe48c
[dv] Remove dead code
elliotb-lowrisc e7fc2c9
[dv] Disable pattgen+uart top monitors by default
elliotb-lowrisc 9a9c60e
[dv] Disable UART DPI model when bypassed
elliotb-lowrisc 0939659
[dv] Improve UART randomisability
elliotb-lowrisc 88fcdae
[dv] Switch to new & improved top-level UART tests
elliotb-lowrisc 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
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
81 changes: 81 additions & 0 deletions
81
hw/top_chip/dv/env/seq_lib/top_chip_dv_uart_rand_baudrate_vseq.sv
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,81 @@ | ||
| // Copyright lowRISC contributors (Sunburst project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| `define CALC_NCO(baud_rate, nco_width, clk_freq_khz) \ | ||
| (baud_rate == BaudRate1p5Mbps && clk_freq_khz == 24_000) ? 16'hffff : \ | ||
| (longint'(baud_rate) * (2**(nco_width+4))) / (clk_freq_khz * 1000) | ||
|
|
||
| class top_chip_dv_uart_rand_baudrate_vseq extends top_chip_dv_uart_tx_rx_vseq; | ||
| // import top_chip_system_pkg::PeriClkFreq; | ||
| `uvm_object_utils(top_chip_dv_uart_rand_baudrate_vseq) | ||
| `uvm_object_new | ||
|
|
||
| localparam NCO_WIDTH = 16; | ||
|
|
||
| int uart_clk_freq_khz; // Use khz to avoid fractional value. | ||
|
|
||
| rand baud_rate_e baud_rate; | ||
|
|
||
| constraint baud_rate_c { | ||
| // constrain nco not over nco width | ||
| `CALC_NCO(baud_rate, NCO_WIDTH, uart_clk_freq_khz) < (1 << NCO_WIDTH); | ||
| // only test 4 other speeds, <= 115k is slow which may take a few hours to complete the test | ||
| baud_rate > BaudRate115200; | ||
| } | ||
|
|
||
| function void pre_randomize(); | ||
| super.pre_randomize(); | ||
|
|
||
| // if (cfg.chip_clock_source != ChipClockSourceInternal) begin | ||
| // // Uart bus clock is in div4 domain | ||
| // uart_clk_freq_khz = cfg.chip_clock_source * 1000 / 4; // div4 | ||
| // if (cfg.chip_clock_source == ChipClockSourceExternal48Mhz) begin | ||
| // uart_clk_freq_khz = uart_clk_freq_khz * 2; // div2 | ||
| // end | ||
| // end else begin | ||
| // internal uart clock | ||
| uart_clk_freq_khz = top_chip_system_pkg::PeriClkFreq / 1000; | ||
| // end | ||
| endfunction | ||
|
|
||
| function void post_randomize(); | ||
| super.post_randomize(); | ||
| uart_baud_rate = baud_rate; | ||
| endfunction | ||
|
|
||
| virtual task body(); | ||
| // sw_symbol_backdoor_overwrite takes an array as the input | ||
| bit [7:0] uart_freq_arr[8] = {<<byte{uart_baud_rate}}; | ||
|
|
||
| sw_symbol_backdoor_overwrite("kUartBaudrate", uart_freq_arr); | ||
| `uvm_info(`gfn, $sformatf( | ||
| "Backdoor_overwrite: configure uart core clk %0d khz, baud_rate: %s", | ||
| uart_clk_freq_khz, | ||
| baud_rate.name | ||
| ), UVM_LOW) | ||
|
|
||
| // if (cfg.chip_clock_source != ChipClockSourceInternal) begin | ||
| // bit [7:0] use_extclk_arr[] = {cfg.chip_clock_source != ChipClockSourceInternal}; | ||
| // bit [7:0] low_speed_sel_arr[] = {cfg.chip_clock_source == ChipClockSourceExternal48Mhz}; | ||
| // bit [7:0] uart_clk_freq_arr[8] = {<<byte{uart_clk_freq_khz * 1000}}; | ||
|
|
||
| // sw_symbol_backdoor_overwrite("kUseExtClk", use_extclk_arr); | ||
| // sw_symbol_backdoor_overwrite("kUseLowSpeedSel", low_speed_sel_arr); | ||
| // sw_symbol_backdoor_overwrite("kClockFreqPeripheralHz", uart_clk_freq_arr); | ||
| // end | ||
|
|
||
| super.body(); | ||
| endtask | ||
|
|
||
| // // When uart starts to send RX data, check if AST is using extclk if extclk is selected. | ||
| // virtual task send_uart_rx_data(int instance_num, int size = -1, bit random = 0); | ||
| // if (cfg.chip_clock_source != ChipClockSourceInternal) begin | ||
| // `DV_CHECK(cfg.ast_ext_clk_vif.is_ext_clk_in_use(), | ||
| // "expected the external clock to be used for io"); | ||
| // end | ||
| // super.send_uart_rx_data(instance_num, size, random); | ||
| // endtask | ||
|
|
||
| endclass : top_chip_dv_uart_rand_baudrate_vseq | ||
| `undef CALC_NCO |
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
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
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
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.