diff --git a/xls/modules/dma/address_generator_snippet.x b/xls/modules/dma/address_generator_snippet.x deleted file mode 100644 index 56e21ee5d7..0000000000 --- a/xls/modules/dma/address_generator_snippet.x +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2023-2024 The XLS Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Address Generator - -pub struct OutputBundle { address: u32, length: u32 } - -pub struct InputBundle { startAddress: u32, lineCount: u32, lineLength: u32, lineStride: u32 } - -pub fn FuncAddressGenerator - (input: InputBundle) -> OutputBundle[ARRAY_SIZE] { - let arr = OutputBundle[ARRAY_SIZE]:[zero!(), ...]; - let arr = - update(arr, u32:0, OutputBundle { address: input.startAddress, length: input.lineLength }); - - let arr = for (i, arr): (u32, OutputBundle[ARRAY_SIZE]) in u32:1..ARRAY_SIZE { - update( - arr, i, - OutputBundle { - address: - (arr[i - u32:1]).address + NUM_BYTES * (input.lineLength + input.lineStride), - length: input.lineLength - }) - }(arr); - arr -} - -#[test] -fn TestFunction() { - let TestBundle = InputBundle { - startAddress: u32:1000, lineCount: u32:4, lineLength: u32:3, lineStride: u32:2 - }; - - let ARRAY_SIZE = TestBundle.lineCount * TestBundle.lineLength; - let NUM_BYTES = u32:4; - let AddressArray = FuncAddressGenerator(TestBundle); - - trace_fmt!("Address Array = {}", AddressArray); - assert_eq((AddressArray[0]).address, u32:1000); - assert_eq((AddressArray[1]).address, u32:1020); - assert_eq((AddressArray[2]).address, u32:1040); - - assert_eq((AddressArray[0]).length, u32:3); - assert_eq((AddressArray[1]).length, u32:3); - assert_eq((AddressArray[2]).length, u32:3); -}