-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a363f2
commit 3c462c4
Showing
5 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,13 @@ | ||
inst u_register: rggen_external_register #( | ||
ADDRESS_WIDTH: <%= address_width %>, | ||
BUS_WIDTH: <%= bus_width %>, | ||
VALUE_WIDTH: <%= value_width %>, | ||
STROBE_WIDTH: <%= strobe_width %>, | ||
START_ADDRESS: <%= start_address %>, | ||
BYTE_SIZE: <%= byte_size %> | ||
)( | ||
i_clk: <%= register_block.clock %>, | ||
i_rst: <%= register_block.reset %>, | ||
register_if: <%= register_if %>, | ||
bus_if: <%= bus_if %> | ||
); |
This file contains 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 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,88 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'register/type/external' do | ||
include_context 'clean-up builder' | ||
include_context 'veryl common' | ||
|
||
before(:all) do | ||
RgGen.enable(:global, [:bus_width, :address_width, :enable_wide_register]) | ||
RgGen.enable(:register_block, :byte_size) | ||
RgGen.enable(:register, [:name, :type, :offset_address, :size]) | ||
RgGen.enable(:register, :type, :external) | ||
RgGen.enable(:bit_field, :name) | ||
RgGen.enable(:register_block, :veryl_top) | ||
RgGen.enable(:register, :veryl_top) | ||
end | ||
|
||
def create_registers(&body) | ||
create_veryl(&body).registers | ||
end | ||
|
||
it 'パラメータ#strobe_widthを持つ' do | ||
registers = create_registers do | ||
byte_size 256 | ||
register { name 'register_0'; offset_address 0x00; type :external; size [1] } | ||
end | ||
|
||
expect(registers[0]) | ||
.to have_param( | ||
:register_block, :strobe_width, | ||
name: 'REGISTER_0_STROBE_WIDTH', type: :int, default: 4 | ||
) | ||
end | ||
|
||
it 'modport #bus_ifを持つ' do | ||
registers = create_registers do | ||
byte_size 256 | ||
register { name 'register_0'; offset_address 0x00; type :external; size [1] } | ||
end | ||
|
||
expect(registers[0]) | ||
.to have_modport( | ||
:register_block, :bus_if, | ||
name: 'register_0_bus_if', interface_type: 'rggen_bus_if', modport: 'master' | ||
) | ||
end | ||
|
||
describe '#generate_code' do | ||
it 'rggen_exernal_registerをインスタンスするコードを出力する' do | ||
registers = create_registers do | ||
byte_size 256 | ||
register { name 'register_0'; offset_address 0x00; type :external; size [1] } | ||
register { name 'register_1'; offset_address 0x80; type :external; size [32] } | ||
end | ||
|
||
expect(registers[0]).to generate_code(:register, :top_down, <<~'VERYL') | ||
inst u_register: rggen_external_register #( | ||
ADDRESS_WIDTH: 8, | ||
BUS_WIDTH: 32, | ||
VALUE_WIDTH: 32, | ||
STROBE_WIDTH: REGISTER_0_STROBE_WIDTH, | ||
START_ADDRESS: 8'h00, | ||
BYTE_SIZE: 4 | ||
)( | ||
i_clk: i_clk, | ||
i_rst: i_rst, | ||
register_if: register_if[0], | ||
bus_if: register_0_bus_if | ||
); | ||
VERYL | ||
|
||
expect(registers[1]).to generate_code(:register, :top_down, <<~'VERYL') | ||
inst u_register: rggen_external_register #( | ||
ADDRESS_WIDTH: 8, | ||
BUS_WIDTH: 32, | ||
VALUE_WIDTH: 32, | ||
STROBE_WIDTH: REGISTER_1_STROBE_WIDTH, | ||
START_ADDRESS: 8'h80, | ||
BYTE_SIZE: 128 | ||
)( | ||
i_clk: i_clk, | ||
i_rst: i_rst, | ||
register_if: register_if[1], | ||
bus_if: register_1_bus_if | ||
); | ||
VERYL | ||
end | ||
end | ||
end |
This file contains 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