From WikiChip
Editing User talk:David

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page is not enabled for semantic in-text annotations due to namespace restrictions. Details about how to enable the namespace can be found on the configuration help page.

Latest revision Your text
Line 109: Line 109:
  
 
<source lang="Lua">
 
<source lang="Lua">
[...]
+
function append_packaging_data(infobox, arg_name, pdata)
 +
    local package_name = origArgs[arg_name]
 +
    if not package_name or package_name == '' then return end
 +
 
 +
    -- Reject unexpected input, esp. smw.ask operators []:|?*~
 +
    -- Should display error msg
 +
    if mw.ustring.find(package_name, '[^%w %-+._,/]') then return end
 +
 
 +
    local package_location, info, result = {}
 +
    local page_name = package_name
 +
    for field in string.gmatch(package_name, "([^,]+),?") do
 +
        table.insert(package_location, field)
 +
    end
 +
    if #package_location > 1 then
 +
        page_name = package_location[1] .. '/packages/' .. package_location[2]
 +
        info = pdata['packages'][package_location[1]][package_location[2]]
 +
    end
 +
    if mw.smw then
 +
        result = mw.smw.ask('[[Category:all ic packages]][[' .. page_name .. ']]' ..
 +
            '|?package|?package type|?package pins|?package pitch' ..
 +
            '|?package length|?package width|?package height|?socket')
 +
    end
 +
    local dim_props = {'package length', 'package width', 'package height'}
 +
    if type(result) == 'table' and #result >= 1 and result[1]['package'] then
 +
        info = result[1]
 +
    else
 +
        if not info then return end -- should display error msg
 +
        page_name = nil
 +
        for i, name in ipairs(dim_props)
 +
            do info[name] = info.p_size and info.p_size[i] or nil end
 +
    end
 +
 
 +
    local function tabled(x) return type(x) == 'table' and x or { x } end
 +
    local function show(label, text)
 +
        if not text or text == '' then return end
 +
        infobox:node(p.add_entry(label, mw.html.create('td'):wikitext(text)))
 +
    end
 +
    local function param(a)
 +
        local prop_names = unpack(a)
 +
        local text, sep = '', ''
 +
        for i, prop_name in ipairs(tabled(prop_names)) do
 +
            local values = info[prop_name] -- single value or table
 +
            if values then
 +
                local n_values = 0
 +
                for j, value in ipairs(tabled(values)) do
 +
                    if value and value ~= '' then
 +
                        if a.set_prop then p.set_val(a.set_prop, value) end
 +
                        text = text .. sep .. value
 +
                        sep = a.sep or ', '
 +
                        n_values = n_values + 1
 +
                        if n_values >= (a.max_values or 1) then break end
 +
                    end
 +
                end
 +
            end
 +
        end
 +
        return text
 +
    end
 +
    local p_type_text, p_type_abbr = param{{'package type', 'p_type'}}, ''
 +
    if p_type_text ~= '' and mw.ustring.len(p_type_text) <= 10 then
 +
        p_type_abbr = ' (' .. p_type_text .. ')'
 +
        p_type_text = ''
 +
    end
 +
    local p_name = param{{'package', 'p_name'}, set_prop='package', max_values=10}
 +
    if p_name ~= '' then
 +
        if page_name then p_name = '[[' .. page_name .. '|' .. p_name .. ']]' end
 +
        show('Package', p_name .. p_type_abbr)
 +
    end
 +
    show('Package Type', p_type_text)
 +
    show('Dimension', param{dim_props, sep=' × '})
 +
    show('Pitch', param{{'package pitch', 'p_pitch'}, max_values=2, sep=' × '})
 +
    show('Contacts', param{{'package pins', 'p_contacts'}})
 +
    show('Socket', param{{'socket', 'p_socket'}, set_prop='socket', max_values=10})
 +
end
 
</source>
 
</source>
  
Of course it would help if [[Module:package]], which already accepts the required data as parameters, would set corresponding package and socket properties, as below for instance. Note the example adds a missing 'package pitch 2' parameter and limits 'package dimension' to three values rather than ten. The proposed property names were already used in subobjects by templates like [[Template:packages/cavium/fcbga-1217]] invoked by the obsolete Module:chip 'package module' parameter. I would prefer a property 'package contacts' over 'package pins' though. Regrettably most of these properties are currently undefined and default to type Page <span class="plainlinks">([https://en.wikichip.org/w/index.php?title=Special%3AProperties&property=package 1] [https://en.wikichip.org/w/index.php?title=Special%3AProperties&property=socket 2])</span> so they won't display nicely. For another obstacle on Wikichip property page changes do not seem to enter the SMW database voluntarily. Take for instance [[Property:l1$ size]] which requests to be displayed in KiB but shows MiB, or [[Property:integrated gpu execution units]] which is typed as Number but still defaults to Page. Also package properties may not enter the database immediately even if listed in a package page fact box, a [[Special:Ask/-5B-5BCategory-3Aall-20ic-20packages-5D-5D/-5B-5Bamd-2Fpackages-2Fsocket_sp5-5D-5D/-3Fpackage/-3Fpackage-20type/-3Fpackage-20pins/-3Fpackage-20pitch/-3Fpackage-20length/-3Fpackage-20width/-3Fpackage-20height/-3Fsocket|manual query]] will show the problem.
+
In the main function:
 +
<source lang="Lua">
 +
    [...]
 +
    -- Packaging
 +
    local has_arg_pkg_name = has_arg('package name') or has_arg('package name 1')
 +
    if has_arg('package module 1') or has_arg_pkg_name or has_arg('back image') then
 +
        p.add_separator(infobox, 'Packaging')
 +
    end
 +
 
 +
    if has_arg_pkg_name then
 +
        local pdata = require('Module:packaging data')
 +
        -- Also accept name, name 2, name 3 for consistency.
 +
        append_packaging_data(infobox, 'package name', pdata)
 +
        for i = 1, 10 do
 +
            append_packaging_data(infobox, 'package name ' .. i, pdata)
 +
        end
 +
    end
 +
    [...]
 +
</source>
 +
 
 +
Of course it would help if [[Module:package]], which already accepts the required data as parameters, would set corresponding package and socket properties, as below for instance. Note the example adds a missing 'package pitch 2' parameter and limits 'package dimension' to three values rather than ten. The proposed property names were already used in subobjects by templates like [[Template:packages/cavium/fcbga-1217]] invoked by the obsolete Module:chip 'package module' parameter. I would prefer a property 'package contacts' over 'package pins' though. Regrettably most of these properties are currently undefined and default to type Page <span class="plainlinks">([https://en.wikichip.org/w/index.php?title=Special%3AProperties&property=package 1] [https://en.wikichip.org/w/index.php?title=Special%3AProperties&property=socket 2])</span> so they won't display nicely. For another obstacle on Wikichip property page changes do not seem to enter the SMW database voluntarily. Take for instance [[Property:l1$ size]] which requests to be displayed in KiB but still shows MiB, or [[Property:integrated gpu execution units]] which is typed as Number but still defaults to Page. Also package properties may not enter the database immediately, a [[Special:Ask/-5B-5BCategory-3Aall-20ic-20packages-5D-5D/-5B-5Bamd-2Fpackages-2Fsocket_sp5-5D-5D/-3Fpackage/-3Fpackage-20type/-3Fpackage-20pins/-3Fpackage-20pitch/-3Fpackage-20length/-3Fpackage-20width/-3Fpackage-20height/-3Fsocket|manual query]] will show the problem.
  
 
<source lang="Lua">
 
<source lang="Lua">
[...]
+
    [...]
</source>
+
    p.add_separator(infobox, 'General Info')
 +
 
 +
    local function entry(a)
 +
        local label, arg_name = unpack(a)
 +
        if not has_arg(arg_name) then return end
 +
        local function text(i, value)
 +
            local prop_name = a.prop_name or arg_name -- {} for none
 +
            if type(prop_name) == 'table' then
 +
                if i > #prop_name then
 +
                    if a.print then return a.print(value) end
 +
                    return value
 +
                end
 +
                prop_name = prop_name[i]
 +
            end
 +
            return '[[' .. prop_name .. '::' .. value ..
 +
                (a.print and ('| ]]' .. a.print(value)) or ']]')
 +
        end
 +
        local td = mw.html.create('td'):wikitext(text(1, arg(arg_name)))
 +
        for i = 2, (a.max_args or 1) do
 +
            local value = origArgs[arg_name .. ' ' .. i]
 +
            if not value or value == '' then break end
 +
            td:wikitext((a.sep or ', ') .. text(i, value))
 +
        end
 +
        if label then infobox:node(p.add_entry(label, td)) end
 +
        return td
 +
    end
 +
    local function link(s) return '[[' .. mw.ustring.lower(s) .. '|' .. s .. ']]' end
 +
 
 +
    local uarch_link
 +
    if has_arg('designer') then
 +
        uarch_link = function(s) return '[[' .. mw.ustring.lower(arg('designer') ..
 +
            '/microarchitectures/' .. s) .. '|' .. s .. ']]' end
 +
        local td = entry{nil, 'designer', max_args=10, print=link}
 +
        infobox:node(p.add_entry('Designer', td:attr('style', 'width: 99%;')))
 +
    end
  
Kind regards, [[User:QuietRub|QR]] ([[User talk:QuietRub|talk]]) 03:47, 13 March 2023 (EDT)
+
    if has_arg('first launched') or has_arg('first announced') then
 +
        local release, sep = mw.html.create('td'), ''
 +
        if has_arg('first announced') then
 +
            release:wikitext('[[first announced::' .. arg('first announced') .. ']] (announced)')
 +
            sep = '<br/>'
 +
        end
 +
        if has_arg('first launched') then
 +
            release:wikitext(sep .. '[[first launched::' .. arg('first launched') .. ']] (launched)')
 +
        end
 +
        infobox:node(p.add_entry('Introduction', release))
 +
    end
  
: Thanks for the admin rights. I made the proposed changes, seems to work as planned. May I suggest an infobox class for Module:chip, core, microarchitecture, and package? They duplicate a lot of code, it could be more readable, and shared code would promote a common appearance. For instance core and package use in-text annotations to set properties, so e.g. [[amd/cores/milan]] displays a warning about the "7 nm+" process using an unknown unit. SMW also displays conversion pop-ups for quantity properties, perhaps useful to compare metric and customary units like inches or mils. Module:chip and microarchitecture use #set exclusively, so [[apple/ax/a12x]] has no pop-ups and is quiet about several improper values and why 'base frequency' is not set. Well an infobox class taking care of such details could do either and switch easily. [[User:QuietRub|QR]] ([[User talk:QuietRub|talk]]) 02:36, 2 April 2023 (EDT)
+
    entry{'Market', 'market', max_args=5, prop_name='market segment'}
 +
    entry{'Microarchitecture', 'microarch', max_args=10,
 +
        prop_name='microarchitecture', print=uarch_link}
 +
    entry{'Chipset', 'chipset', max_args=10}
 +
    entry{'<abbr title="Thermal Design Power">TDP</abbr>', 'tdp', max_args=10}
  
== Semantic citations ==
+
    if has_arg('package name') or has_arg('package type') then
What is your opinion on semantic citations? Citations are useful to track obscure facts or record documents which may be of interest to other researchers, but one has to look up document details (title, author, publication date, URL, etc.) every time, corrections on multiple pages e.g. when the URL changes are laborious, and long references clutter up the page. Semantic citations would keep all the details in semantic properties on one page and use a query to insert them on other pages.
+
        p.add_separator(infobox, 'Package')
 +
        entry{'Name', 'package name', max_args=10, prop_name='package', sep=',<br/>'}
 +
        entry{'Type', 'package type'}
 +
        entry{'Contacts', 'package contacts', prop_name='package pins'}
 +
        entry{'Dimension', 'package dimension', max_args=3, sep=' × ',
 +
            prop_name={'package length', 'package width', 'package height'}}
 +
        entry{'Pitch', 'package pitch', max_args=2, sep=' × '}
 +
    end
  
There is a promising [https://www.mediawiki.org/wiki/Extension:Semantic_Cite Semantic Cite extension], however it comes with downsides such as not being installed on Wikichip, using admin-only pages to control its operation, enforcing conventions like having a single list of references at the bottom of the page (unlike e.g. {{amd|CPUID}}), and not cooperating with the Cite extension so if documents outside the SMW database are referenced one may end up with two reference tables. Fortunately something similar can be implemented using basic SMW features and templates:
+
    if has_arg('socket name') or has_arg('socket type') then
 +
        p.add_separator(infobox, 'Socket')
 +
        entry{'Name', 'socket name', prop_name='socket', max_args=10, sep=',<br/>'}
 +
        entry{'Type', 'socket type', prop_name={}}
 +
    end
 +
    [...]
 +
</source>
  
Each citable document has a page which sets properties containing the document details. That could be a File: page although for copyright reasons I would expect more often an ordinary, very short page with an external link to the document. Another option, not mutually exclusive, is to store details in one subobject per document. Subobjects can be placed on pages listing documents in any number, and a template can help structure the data. Subobjects have no name or category but a query can find "citation resource" subobjects because they all set a citation_key property. The key is one way to retrieve document data, and a suitable template can format it. A less taxing option is to format the citation at the source, a side effect of the subobject template, and store the output in a citation_text property. A Template:cite would simply insert the retrieved citation_text in a page, e.g. in the bibliography section. A Template:citeref can create a reference by adding &lt;ref> tags. Document tables could be produced in the same way as chip tables, with free text search in titles or keywords, the subobject template setting additional properties as needed. [[User:QuietRub|QR]] ([[User talk:QuietRub|talk]]) 02:36, 2 April 2023 (EDT)
+
Kind regards, [[User:QuietRub|QR]] ([[User talk:QuietRub|talk]]) 03:47, 13 March 2023 (EDT)

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)